index-knowledge by tursodatabase/turso
npx skills add https://github.com/tursodatabase/turso --skill index-knowledge生成层级化的 AGENTS.md 文件。根目录 + 按复杂度评分的子目录。
--create-new # 读取现有文件 → 删除所有 → 从头重新生成
--max-depth=2 # 限制目录深度(默认值:5)
默认模式:更新模式(修改现有文件 + 在需要时创建新文件)
TodoWrite([
{ id: "discovery", content: "启动探索代理 + LSP 代码映射 + 读取现有文件", status: "pending", priority: "high" },
{ id: "scoring", content: "为目录评分,确定位置", status: "pending", priority: "high" },
{ id: "generate", content: "生成 AGENTS.md 文件(根目录 + 子目录)", status: "pending", priority: "high" },
{ id: "review", content: "去重、验证、精简", status: "pending", priority: "medium" }
])
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
在单条消息中的多个 Task 调用会并行执行。结果直接返回。
// 所有 Task 调用在一条消息中 = 并行执行
Task(
description="project structure",
subagent_type="explore",
prompt="项目结构:预测检测到的语言的标准模式 → 仅报告偏差"
)
Task(
description="entry points",
subagent_type="explore",
prompt="入口点:查找主文件 → 报告非标准组织方式"
)
Task(
description="conventions",
subagent_type="explore",
prompt="约定:查找配置文件(.eslintrc、pyproject.toml、.editorconfig)→ 报告项目特定规则"
)
Task(
description="anti-patterns",
subagent_type="explore",
prompt="反模式:查找 'DO NOT'、'NEVER'、'ALWAYS'、'DEPRECATED' 注释 → 列出禁止的模式"
)
Task(
description="build/ci",
subagent_type="explore",
prompt="构建/CI:查找 .github/workflows、Makefile → 报告非标准模式"
)
Task(
description="test patterns",
subagent_type="explore",
prompt="测试模式:查找测试配置、测试结构 → 报告独特的约定"
)
| 因素 | 阈值 | 额外代理 |
|---|---|---|
| 总文件数 | >100 | 每 100 个文件 +1 |
| 总行数 | >10k | 每 10k 行 +1 |
| 目录深度 | ≥4 | 深度探索 +2 |
| 大文件(>500 行) | >10 个文件 | 复杂度热点 +1 |
| Monorepo | 检测到 | 每个包/工作区 +1 |
| 多语言 | >1 | 每种语言 +1 |
# 首先测量项目规模
total_files=$(find . -type f -not -path '*/node_modules/*' -not -path '*/.git/*' | wc -l)
total_lines=$(find . -type f \( -name "*.ts" -o -name "*.py" -o -name "*.go" \) -not -path '*/node_modules/*' -exec wc -l {} + 2>/dev/null | tail -1 | awk '{print $1}')
large_files=$(find . -type f \( -name "*.ts" -o -name "*.py" \) -not -path '*/node_modules/*' -exec wc -l {} + 2>/dev/null | awk '$1 > 500 {count++} END {print count+0}')
max_depth=$(find . -type d -not -path '*/node_modules/*' -not -path '*/.git/*' | awk -F/ '{print NF}' | sort -rn | head -1)
生成示例(全部在一条消息中以便并行执行):
// 500 个文件,50k 行,深度 6,15 个大文件 → 生成额外代理
Task(
description="large files",
subagent_type="explore",
prompt="大文件分析:查找 >500 行的文件,报告复杂度热点"
)
Task(
description="deep modules",
subagent_type="explore",
prompt="深度模块(深度 4+):查找隐藏模式、内部约定"
)
Task(
description="cross-cutting",
subagent_type="explore",
prompt="横切关注点:查找跨目录的共享工具"
)
// ... 根据计算结果生成更多
当 Task 代理执行时,主会话执行:
# 目录深度 + 文件计数
find . -type d -not -path '*/\.*' -not -path '*/node_modules/*' -not -path '*/venv/*' -not -path '*/dist/*' -not -path '*/build/*' | awk -F/ '{print NF-1}' | sort -n | uniq -c
# 每个目录的文件数(前 30)
find . -type f -not -path '*/\.*' -not -path '*/node_modules/*' | sed 's|/[^/]*$||' | sort | uniq -c | sort -rn | head -30
# 按扩展名统计代码集中度
find . -type f \( -name "*.py" -o -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.go" -o -name "*.rs" \) -not -path '*/node_modules/*' | sed 's|/[^/]*$||' | sort | uniq -c | sort -rn | head -20
# 现有的 AGENTS.md / CLAUDE.md
find . -type f \( -name "AGENTS.md" -o -name "CLAUDE.md" \) -not -path '*/node_modules/*' 2>/dev/null
For each existing file found:
Read(filePath=file)
Extract: key insights, conventions, anti-patterns
Store in EXISTING_AGENTS map
如果使用 --create-new:首先读取所有现有文件(保留上下文)→ 然后删除所有 → 重新生成。
lsp_servers() # 检查可用性
# 入口点(并行)
lsp_document_symbols(filePath="src/index.ts")
lsp_document_symbols(filePath="main.py")
# 关键符号(并行)
lsp_workspace_symbols(filePath=".", query="class")
lsp_workspace_symbols(filePath=".", query="interface")
lsp_workspace_symbols(filePath=".", query="function")
# 顶级导出的中心性
lsp_find_references(filePath="...", line=X, character=Y)
LSP 备用方案:如果不可用,则依赖探索代理 + AST-grep。
合并:bash + LSP + 现有文件 + Task 代理结果。将 "discovery" 标记为 completed。
将 "scoring" 标记为 in_progress。
| 因素 | 权重 | 高阈值 | 来源 |
|---|---|---|---|
| 文件数 | 3x | >20 | bash |
| 子目录数 | 2x | >5 | bash |
| 代码比例 | 2x | >70% | bash |
| 独特模式 | 1x | 拥有自己的配置 | explore |
| 模块边界 | 2x | 拥有 index.ts/init.py | bash |
| 符号密度 | 2x | >30 个符号 | LSP |
| 导出数量 | 2x | >10 个导出 | LSP |
| 引用中心性 | 3x | >20 个引用 | LSP |
| 分数 | 操作 |
|---|---|
| 根目录 (.) | 总是创建 |
| > 15 | 创建 AGENTS.md |
| 8-15 | 如果是独立领域则创建 |
| < 8 | 跳过(由父目录覆盖) |
AGENTS_LOCATIONS = [
{ path: ".", type: "root" },
{ path: "src/hooks", score: 18, reason: "high complexity" },
{ path: "src/api", score: 12, reason: "distinct domain" }
]
将 "scoring" 标记为 completed。
将 "generate" 标记为 in_progress。
# 项目知识库
**生成时间:** {TIMESTAMP}
**提交:** {SHORT_SHA}
**分支:** {BRANCH}
## 概述
{1-2 句话:项目是什么 + 核心技术栈}
## 结构
\`\`\`
{root}/
├── {dir}/ # {仅当目的不明确时说明}
└── {entry}
\`\`\`
## 查找位置
| 任务 | 位置 | 备注 |
|------|----------|-------|
## 代码映射
{来自 LSP - 如果不可用或项目文件数 <10 则跳过}
| 符号 | 类型 | 位置 | 引用 | 角色 |
## 约定
{仅包含与标准不同的部分}
## 反模式(本项目)
{本项目明确禁止的模式}
## 独特风格
{项目特定风格}
## 命令
\`\`\`bash
{开发/测试/构建命令}
\`\`\`
## 注意事项
{需要注意的问题}
质量门控:50-150 行,无通用建议,无显而易见的信息。
在一条消息中为每个位置启动通用代理(并行执行):
// 全部在单条消息中 = 并行执行
Task(
description="AGENTS.md for src/hooks",
subagent_type="general",
prompt="为 src/hooks 生成 AGENTS.md
- 原因:高复杂度
- 最多 30-80 行
- 切勿重复父目录内容
- 章节:概述(1 行)、结构(如果子目录 >5 个)、查找位置、约定(如果不同)、反模式
- 直接写入 src/hooks/AGENTS.md"
)
Task(
description="AGENTS.md for src/api",
subagent_type="general",
prompt="为 src/api 生成 AGENTS.md
- 原因:独立领域
- 最多 30-80 行
- 切勿重复父目录内容
- 章节:概述(1 行)、结构(如果子目录 >5 个)、查找位置、约定(如果不同)、反模式
- 直接写入 src/api/AGENTS.md"
)
// ... 为 AGENTS_LOCATIONS 中的每个条目创建一个 Task
结果直接返回。将 "generate" 标记为 completed。
将 "review" 标记为 in_progress。
对于每个生成的文件:
将 "review" 标记为 completed。
=== index-knowledge 完成 ===
模式:{update | create-new}
文件:
✓ ./AGENTS.md (根目录,{N} 行)
✓ ./src/hooks/AGENTS.md ({N} 行)
分析的目录数:{N}
创建的 AGENTS.md 数:{N}
更新的 AGENTS.md 数:{N}
层级结构:
./AGENTS.md
└── src/hooks/AGENTS.md
每周安装次数
431
代码仓库
GitHub 星标数
17.9K
首次出现
2026年1月30日
安全审计
安装于
claude-code315
github-copilot233
opencode173
gemini-cli171
codex171
kimi-cli163
Generate hierarchical AGENTS.md files. Root + complexity-scored subdirectories.
--create-new # Read existing → remove all → regenerate from scratch
--max-depth=2 # Limit directory depth (default: 5)
Default: Update mode (modify existing + create new where warranted)
TodoWrite([
{ id: "discovery", content: "Fire explore agents + LSP codemap + read existing", status: "pending", priority: "high" },
{ id: "scoring", content: "Score directories, determine locations", status: "pending", priority: "high" },
{ id: "generate", content: "Generate AGENTS.md files (root + subdirs)", status: "pending", priority: "high" },
{ id: "review", content: "Deduplicate, validate, trim", status: "pending", priority: "medium" }
])
Mark "discovery" as in_progress.
Multiple Task calls in a single message execute in parallel. Results return directly.
// All Task calls in ONE message = parallel execution
Task(
description="project structure",
subagent_type="explore",
prompt="Project structure: PREDICT standard patterns for detected language → REPORT deviations only"
)
Task(
description="entry points",
subagent_type="explore",
prompt="Entry points: FIND main files → REPORT non-standard organization"
)
Task(
description="conventions",
subagent_type="explore",
prompt="Conventions: FIND config files (.eslintrc, pyproject.toml, .editorconfig) → REPORT project-specific rules"
)
Task(
description="anti-patterns",
subagent_type="explore",
prompt="Anti-patterns: FIND 'DO NOT', 'NEVER', 'ALWAYS', 'DEPRECATED' comments → LIST forbidden patterns"
)
Task(
description="build/ci",
subagent_type="explore",
prompt="Build/CI: FIND .github/workflows, Makefile → REPORT non-standard patterns"
)
Task(
description="test patterns",
subagent_type="explore",
prompt="Test patterns: FIND test configs, test structure → REPORT unique conventions"
)
| Factor | Threshold | Additional Agents |
|---|---|---|
| Total files | >100 | +1 per 100 files |
| Total lines | >10k | +1 per 10k lines |
| Directory depth | ≥4 | +2 for deep exploration |
| Large files ( >500 lines) | >10 files | +1 for complexity hotspots |
| Monorepo | detected | +1 per package/workspace |
| Multiple languages | >1 | +1 per language |
# Measure project scale first
total_files=$(find . -type f -not -path '*/node_modules/*' -not -path '*/.git/*' | wc -l)
total_lines=$(find . -type f \( -name "*.ts" -o -name "*.py" -o -name "*.go" \) -not -path '*/node_modules/*' -exec wc -l {} + 2>/dev/null | tail -1 | awk '{print $1}')
large_files=$(find . -type f \( -name "*.ts" -o -name "*.py" \) -not -path '*/node_modules/*' -exec wc -l {} + 2>/dev/null | awk '$1 > 500 {count++} END {print count+0}')
max_depth=$(find . -type d -not -path '*/node_modules/*' -not -path '*/.git/*' | awk -F/ '{print NF}' | sort -rn | head -1)
Example spawning (all in ONE message for parallel execution):
// 500 files, 50k lines, depth 6, 15 large files → spawn additional agents
Task(
description="large files",
subagent_type="explore",
prompt="Large file analysis: FIND files >500 lines, REPORT complexity hotspots"
)
Task(
description="deep modules",
subagent_type="explore",
prompt="Deep modules at depth 4+: FIND hidden patterns, internal conventions"
)
Task(
description="cross-cutting",
subagent_type="explore",
prompt="Cross-cutting concerns: FIND shared utilities across directories"
)
// ... more based on calculation
While Task agents execute , main session does:
# Directory depth + file counts
find . -type d -not -path '*/\.*' -not -path '*/node_modules/*' -not -path '*/venv/*' -not -path '*/dist/*' -not -path '*/build/*' | awk -F/ '{print NF-1}' | sort -n | uniq -c
# Files per directory (top 30)
find . -type f -not -path '*/\.*' -not -path '*/node_modules/*' | sed 's|/[^/]*$||' | sort | uniq -c | sort -rn | head -30
# Code concentration by extension
find . -type f \( -name "*.py" -o -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.go" -o -name "*.rs" \) -not -path '*/node_modules/*' | sed 's|/[^/]*$||' | sort | uniq -c | sort -rn | head -20
# Existing AGENTS.md / CLAUDE.md
find . -type f \( -name "AGENTS.md" -o -name "CLAUDE.md" \) -not -path '*/node_modules/*' 2>/dev/null
For each existing file found:
Read(filePath=file)
Extract: key insights, conventions, anti-patterns
Store in EXISTING_AGENTS map
If --create-new: Read all existing first (preserve context) → then delete all → regenerate.
lsp_servers() # Check availability
# Entry points (parallel)
lsp_document_symbols(filePath="src/index.ts")
lsp_document_symbols(filePath="main.py")
# Key symbols (parallel)
lsp_workspace_symbols(filePath=".", query="class")
lsp_workspace_symbols(filePath=".", query="interface")
lsp_workspace_symbols(filePath=".", query="function")
# Centrality for top exports
lsp_find_references(filePath="...", line=X, character=Y)
LSP Fallback : If unavailable, rely on explore agents + AST-grep.
Merge: bash + LSP + existing + Task agent results. Mark "discovery" as completed.
Mark "scoring" as in_progress.
| Factor | Weight | High Threshold | Source |
|---|---|---|---|
| File count | 3x | >20 | bash |
| Subdir count | 2x | >5 | bash |
| Code ratio | 2x | >70% | bash |
| Unique patterns | 1x | Has own config | explore |
| Module boundary | 2x | Has index.ts/init.py | bash |
| Symbol density | 2x | >30 symbols | LSP |
| Export count | 2x | >10 exports | LSP |
| Reference centrality |
| Score | Action |
|---|---|
| Root (.) | ALWAYS create |
| > 15 | Create AGENTS.md |
| 8-15 | Create if distinct domain |
| < 8 | Skip (parent covers) |
AGENTS_LOCATIONS = [
{ path: ".", type: "root" },
{ path: "src/hooks", score: 18, reason: "high complexity" },
{ path: "src/api", score: 12, reason: "distinct domain" }
]
Mark "scoring" as completed.
Mark "generate" as in_progress.
# PROJECT KNOWLEDGE BASE
**Generated:** {TIMESTAMP}
**Commit:** {SHORT_SHA}
**Branch:** {BRANCH}
## OVERVIEW
{1-2 sentences: what + core stack}
## STRUCTURE
\`\`\`
{root}/
├── {dir}/ # {non-obvious purpose only}
└── {entry}
\`\`\`
## WHERE TO LOOK
| Task | Location | Notes |
|------|----------|-------|
## CODE MAP
{From LSP - skip if unavailable or project <10 files}
| Symbol | Type | Location | Refs | Role |
## CONVENTIONS
{ONLY deviations from standard}
## ANTI-PATTERNS (THIS PROJECT)
{Explicitly forbidden here}
## UNIQUE STYLES
{Project-specific}
## COMMANDS
\`\`\`bash
{dev/test/build}
\`\`\`
## NOTES
{Gotchas}
Quality gates : 50-150 lines, no generic advice, no obvious info.
Launch general agents for each location in ONE message (parallel execution):
// All in single message = parallel
Task(
description="AGENTS.md for src/hooks",
subagent_type="general",
prompt="Generate AGENTS.md for: src/hooks
- Reason: high complexity
- 30-80 lines max
- NEVER repeat parent content
- Sections: OVERVIEW (1 line), STRUCTURE (if >5 subdirs), WHERE TO LOOK, CONVENTIONS (if different), ANTI-PATTERNS
- Write directly to src/hooks/AGENTS.md"
)
Task(
description="AGENTS.md for src/api",
subagent_type="general",
prompt="Generate AGENTS.md for: src/api
- Reason: distinct domain
- 30-80 lines max
- NEVER repeat parent content
- Sections: OVERVIEW (1 line), STRUCTURE (if >5 subdirs), WHERE TO LOOK, CONVENTIONS (if different), ANTI-PATTERNS
- Write directly to src/api/AGENTS.md"
)
// ... one Task per AGENTS_LOCATIONS entry
Results return directly. Mark "generate" as completed.
Mark "review" as in_progress.
For each generated file:
Mark "review" as completed.
=== index-knowledge Complete ===
Mode: {update | create-new}
Files:
✓ ./AGENTS.md (root, {N} lines)
✓ ./src/hooks/AGENTS.md ({N} lines)
Dirs Analyzed: {N}
AGENTS.md Created: {N}
AGENTS.md Updated: {N}
Hierarchy:
./AGENTS.md
└── src/hooks/AGENTS.md
Weekly Installs
431
Repository
GitHub Stars
17.9K
First Seen
Jan 30, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code315
github-copilot233
opencode173
gemini-cli171
codex171
kimi-cli163
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
136,300 周安装
| 3x |
| >20 refs |
| LSP |