Atris — Codebase Intelligence
Maintain a structured map of the codebase with exact file:line references. One scan, permanent knowledge. Saves 80-95% of tokens on code exploration.
Scope
- - Use in any repo where you need to navigate code.
- Creates
atris/MAP.md as the single navigation index.
MAP-first rule
Before searching for anything in the codebase:
- 1. Read INLINECODE1
- Found your keyword → go directly to file:line. Done.
- Not found → search once with
rg, then add the result to MAP.md
The map gets smarter every time you use it. Never let a discovery go unrecorded.
First time setup
If atris/MAP.md doesn't exist, generate it:
- 1. Create
atris/ folder in the project root - Scan the codebase (rules below)
- Write the result to INLINECODE5
- Tell the user: "Built your codebase map at atris/MAP.md."
If atris/MAP.md already exists, use it. Regenerate only if the user requests it or the map is clearly stale (references missing files, line numbers way off).
How to scan
Skip: node_modules, .git, dist, build, vendor, __pycache__, .venv, .env*, *.key, *.pem, credentials*, INLINECODE18
Use ripgrep to extract structure:
CODEBLOCK0
MAP.md structure
CODEBLOCK1
Extract the top 15-25 most important symbols: entry points, exports, route handlers, main classes, config loaders.
By-Feature Map
Group code by what it does. Every reference includes exact file path and line numbers.
CODEBLOCK2
By-Concern Map
Group by cross-cutting patterns (error handling, logging, auth middleware, etc).
Critical Files
Flag high-impact files with why they matter and key functions with line numbers.
Entry Points
How execution flows — dev server startup, request lifecycle, build pipeline.
Keeping it fresh
Update MAP.md surgically when the codebase changes:
- - New file → add to relevant section
- Moved/renamed → update all references
- New important function → add to Quick Reference
- Deleted file → remove from map
- Major refactor → regenerate affected sections
Small updates, not full regeneration. The map evolves with the code.
Anti-patterns
- - Searching without checking MAP first
- Letting discoveries go unrecorded
- Regenerating the full map when a surgical update would do
- Including secrets, credentials, or .env files in the map
- Guessing file locations instead of using the index
Atris — 代码库智能导航
维护一份包含精确文件:行引用的代码库结构化地图。一次扫描,永久知识。在代码探索中节省80-95%的令牌消耗。
适用范围
- - 在任何需要导航代码的仓库中使用。
- 创建 atris/MAP.md 作为唯一的导航索引。
MAP优先规则
在代码库中搜索任何内容之前:
- 1. 读取 atris/MAP.md
- 找到你的关键词 → 直接跳转到文件:行。完成。
- 未找到 → 使用 rg 搜索一次,然后将结果添加到 MAP.md 中
地图会随着每次使用而变得更智能。绝不让任何发现被遗漏。
首次设置
如果 atris/MAP.md 不存在,则生成它:
- 1. 在项目根目录创建 atris/ 文件夹
- 扫描代码库(规则见下文)
- 将结果写入 atris/MAP.md
- 告知用户:已在 atris/MAP.md 构建你的代码库地图。
如果 atris/MAP.md 已存在,则使用它。仅在用户要求或地图明显过时(引用缺失文件、行号严重偏离)时重新生成。
扫描方式
跳过:node_modules、.git、dist、build、vendor、pycache、.venv、.env、.key、.pem、credentials、secrets*
使用 ripgrep 提取结构:
bash
关键定义
rg ^(export|function|class|const|def |async def |router\.|app\.|@app\.) --line-number -g !node_modules -g !.git -g !dist -g !.env*
路由定义
rg (get|post|put|delete|patch)\s
\( --line-number -g .ts -g
.js -g .py
入口点
rg listen|createServer|app\.start|if
name --line-number
MAP.md 结构
markdown
MAP.md — [项目名称] 导航指南
由 Atris 生成 | 最后更新:YYYY-MM-DD
快速参考
rg functionName path/to/file.ext # 描述(第 N 行)
rg className path/to/file.ext # 描述(第 N 行)
提取最重要的 15-25 个符号:入口点、导出、路由处理器、主类、配置加载器。
按功能地图
按功能对代码进行分组。每个引用都包含精确的文件路径和行号。
markdown
功能:用户认证
目的: 登录、注册、令牌管理
- - 入口: src/auth/login.ts:45-89 (handleLogin)
- 验证: src/auth/validate.ts:12-67 (validateToken)
- 模型: src/models/user.ts:8-34 (User schema)
- 路由: src/routes/auth.ts:5-28 (POST /login, POST /register)
按关注点地图
按横切模式分组(错误处理、日志记录、认证中间件等)。
关键文件
标记高影响文件,说明其重要性,并列出关键函数及其行号。
入口点
执行流程——开发服务器启动、请求生命周期、构建流水线。
保持更新
当代码库发生变化时,精确更新 MAP.md:
- - 新文件 → 添加到相关章节
- 移动/重命名 → 更新所有引用
- 新增重要函数 → 添加到快速参考
- 删除文件 → 从地图中移除
- 重大重构 → 重新生成受影响的章节
小更新,而非完全重新生成。地图随代码一起演进。
反模式
- - 未先检查 MAP 就进行搜索
- 让发现被遗漏
- 在精确更新即可时重新生成完整地图
- 在地图中包含密钥、凭证或 .env 文件
- 猜测文件位置而非使用索引