Stop Wasting Tokens: I Built a File-Mapping Standard for AI-Assisted Development

Stop Wasting Tokens: I Built a File-Mapping Standard for AI-Assisted Development

停止浪费 Token:我为 AI 辅助开发构建了一个文件映射标准

Every time I started a new AI chat session, it read my entire codebase. 50 files. Thousands of tokens. On every single message. Whether I was asking about authentication, database schema, or a single UI component — the AI read everything. I’m 16 and building AI-powered products. Token costs add up fast. Context windows fill up. The AI loses track of older files. Responses slow down. So I built something to fix it. 每当我开启一个新的 AI 对话会话时,它都会读取我整个代码库。50 个文件,数千个 Token。每一条消息都是如此。无论我是在询问身份验证、数据库架构还是单个 UI 组件,AI 都会读取所有内容。我今年 16 岁,正在开发 AI 驱动的产品。Token 成本累积得很快,上下文窗口也会被填满,AI 还会丢失对旧文件的追踪,响应速度也变慢了。所以我构建了一个解决方案。

The Problem

问题所在

When you work with AI on large projects, you face a choice: Give the AI too much context → burns tokens, hits context limits, slower responses Give it too little → AI misses important files, makes wrong assumptions There’s no middle ground — or at least there wasn’t. 当你在大型项目中使用 AI 时,你面临一个选择: 给 AI 过多上下文 → 消耗 Token,触及上下文限制,响应变慢 给 AI 过少上下文 → AI 会遗漏重要文件,做出错误的假设 这中间没有折中方案——或者说,以前没有。

Introducing FolioDux

介绍 FolioDux

FolioDux is a lightweight, open-source file-mapping standard for AI-assisted development. The idea is simple: instead of giving your AI every file, you give it a compact index that tells it where everything is and what it does. The AI reads the index first, identifies the relevant files, and reads only those. One file. Two rules. Any AI. It works with Claude, ChatGPT, Gemini, Cursor, Copilot — any tool that accepts a system prompt. FolioDux 是一个轻量级的开源文件映射标准,专为 AI 辅助开发而设计。其理念很简单:与其把所有文件都丢给 AI,不如给它一个紧凑的索引,告诉它文件在哪里以及它们的作用。AI 会先读取索引,识别出相关文件,然后只读取这些文件。一个文件,两条规则,适用于任何 AI。它兼容 Claude、ChatGPT、Gemini、Cursor、Copilot 等任何支持系统提示词(System Prompt)的工具。

How It Works

工作原理

You add one file — FOLIODUX.md — to your project root. 你需要在项目根目录下添加一个文件 —— FOLIODUX.md

(Example content omitted for brevity) (此处省略示例内容)

Then you add two rules to your AI system prompt: 然后,在你的 AI 系统提示词中添加两条规则:

RULE 1 — NAVIGATE BEFORE RESPONDING At the start of every response, before reading any other file:

  1. Read FOLIODUX.md in full.
  2. Check TASKS — if the request matches a keyword, read ONLY those files.
  3. If no match in TASKS, scan INDEX keywords to identify relevant files.
  4. Read ONLY the identified files. Never read the full codebase unless asked. 规则 1 — 响应前先导航 在每次响应开始时,在读取任何其他文件之前:
  5. 完整读取 FOLIODUX.md
  6. 检查 TASKS —— 如果请求匹配关键词,则只读取这些文件。
  7. 如果 TASKS 中没有匹配项,扫描 INDEX 关键词以识别相关文件。
  8. 只读取识别出的文件。除非被要求,否则永远不要读取整个代码库。

RULE 2 — UPDATE AFTER CREATING After creating any new file, add one line to FOLIODUX.md INDEX: {filename} | {type} | {keywords — no articles, no filler verbs, max 8 words}. Update TASKS and GROUPS if needed. 规则 2 — 创建后更新 在创建任何新文件后,在 FOLIODUX.mdINDEX 中添加一行:{文件名} | {类型} | {关键词 — 无冠词,无填充动词,最多 8 个词}。如有必要,更新 TASKSGROUPS

That’s it. Your AI now navigates the project like a developer who already knows the codebase. 就是这样。你的 AI 现在可以像一个熟悉代码库的开发者一样在项目中导航了。

Before vs After

前后对比

Without FolioDux: You ask “fix the login bug”. Your AI reads all 50 files. Uses 4,000 tokens before even starting to think about your question. Maybe hits the context limit halfway through. With FolioDux: Your AI reads FOLIODUX.md, finds auth/loginAuthView.tsx, authService.ts, server.ts, reads 3 files. Uses ~300 tokens. Answers faster and more accurately. 使用 FolioDux 前: 你问“修复登录 Bug”。AI 读取所有 50 个文件。在开始思考你的问题之前就消耗了 4,000 个 Token。甚至可能在处理过程中触及上下文限制。 使用 FolioDux 后: AI 读取 FOLIODUX.md,找到 auth/loginAuthView.tsx, authService.ts, server.ts,只读取 3 个文件。仅消耗约 300 个 Token。回答更快、更准确。

Quick Start

快速开始

Step 1 — Generate your FOLIODUX.md automatically curl -O https://raw.githubusercontent.com/matteo-turri/foliodux/main/foliodux-init.mjs node foliodux-init.mjs The CLI script scans your project, detects the tech stack, classifies every file, and generates FOLIODUX.md in seconds. 第一步 — 自动生成 FOLIODUX.md (运行上述命令) CLI 脚本会扫描你的项目,检测技术栈,对每个文件进行分类,并在几秒钟内生成 FOLIODUX.md

Step 2 — Complete the TASKS section Open FOLIODUX.md and map your most common requests to the files they need. 第二步 — 完善 TASKS 部分 打开 FOLIODUX.md,将你最常见的请求映射到它们所需的文件上。

Step 3 — Add the protocol to your AI tool Copy the two rules above into your AI tool’s system prompt. Templates are available in the repo. 第三步 — 将协议添加到你的 AI 工具中 将上述两条规则复制到你的 AI 工具的系统提示词中。仓库中提供了模板。

Design Principles

设计原则

  • One file. No config, no database, no server. Just a Markdown file.
  • Tool-agnostic. Works with any AI that accepts a system prompt.
  • Token-first. Every design decision optimizes for token efficiency.
  • Self-updating. Rule 2 makes the AI maintain the index automatically.
  • Human-readable. Valid Markdown. Open, edit, and version-control it like any other file.
  • 一个文件。 无需配置、数据库或服务器。只需一个 Markdown 文件。
  • 工具无关。 适用于任何支持系统提示词的 AI。
  • Token 优先。 每个设计决策都针对 Token 效率进行了优化。
  • 自动更新。 规则 2 让 AI 能够自动维护索引。
  • 人类可读。 有效的 Markdown。像其他文件一样打开、编辑和进行版本控制。

Get Started

开始使用

The full project — including the CLI script, prompt templates, and a complete example — is on GitHub: → github.com/matteo-turri/foliodux Open source. MIT license. Stars and feedback welcome. Built this to solve my own problem while working on my projects. I’m 16 and based in Milan — if you try FolioDux, let me know what you think in the comments. 完整项目(包括 CLI 脚本、提示词模板和完整示例)已发布在 GitHub 上: → github.com/matteo-turri/foliodux 开源,MIT 协议。欢迎 Star 和反馈。我构建这个工具是为了解决我在开发项目时遇到的问题。我今年 16 岁,住在米兰——如果你尝试了 FolioDux,请在评论区告诉我你的想法。