[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6E1C1S4GGD447NC3B3B7KKQ":3,"skill-same:01M6E1C1S4GGD447NC3B3B7KKQ":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":35,"linkOnly":36,"markdownContent":37,"markdownBody":38,"frontMatter":39,"refName":40,"commitSha":41,"skillDirectory":42,"forksCount":43,"repositoryHtmlUrl":44,"repositoryHomepageUrl":45,"ownerHtmlUrl":46,"ownerBlogUrl":47,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M6E1C1S4GGD447NC3B3B7KKQ","init-deep",null,"Generate hierarchical AGENTS.md and ensure paired CLAUDE.md files for codebases. Creates root AGENTS.md + CLAUDE.md plus complexity-scored subdirectory files. Use when user asks to \"generate AGENTS.md files\", \"create codebase knowledge base\", \"run \u002Finit-deep\", or wants comprehensive project documentation. Supports update mode (default) and --create-new flag to regenerate from scratch.","AkaraChen\u002Faghub","AkaraChen","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F85140972?v=4","01M6E197RY34TPAFK03227R387","01M6E197X876C4624H0VJC1E5H",271,"MIT","https:\u002F\u002Fgithub.com\u002FAkaraChen\u002Faghub\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Finit-deep\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"deep","init deep","init","user","project","knowledge base","base","default","files","complexity","use","knowledge","update","run","generate","create","documentation","2026-11-10 10:12:30",false,"---\nname: init-deep\ndescription: Generate hierarchical AGENTS.md and ensure paired CLAUDE.md files for codebases. Creates root AGENTS.md + CLAUDE.md plus complexity-scored subdirectory files. Use when user asks to \"generate AGENTS.md files\", \"create codebase knowledge base\", \"run \u002Finit-deep\", or wants comprehensive project documentation. Supports update mode (default) and --create-new flag to regenerate from scratch.\n---\n\n# \u002Finit-deep\n\nGenerate hierarchical AGENTS.md files. Ensure every AGENTS.md has a paired CLAUDE.md (and vice versa) via symlinks. Root + complexity-scored subdirectories + all monorepo packages.\n\n## Usage\n\n```\n\u002Finit-deep                      # Update mode: modify existing + create new where warranted\n\u002Finit-deep --create-new         # Read existing → remove all → regenerate from scratch\n\u002Finit-deep --max-depth=2        # Limit directory depth (default: 3)\n```\n\n---\n\n## Workflow (High-Level)\n\n1. **Discovery + Analysis** (concurrent)\n    - Fire background explore agents immediately\n    - Main session: bash structure + LSP codemap + read existing AGENTS.md and CLAUDE.md\n2. **Score & Decide** - Determine AGENTS.md\u002FCLAUDE.md locations from merged findings\n3. **Generate** - Root first, then subdirs in parallel\n4. **Review** - Deduplicate, trim, validate, ensure pairs\n\n\u003Ccritical>\n**TodoWrite ALL phases. Mark in_progress → completed in real-time.**\n```\nTodoWrite([\n  { id: \"discovery\", content: \"Fire explore agents + LSP codemap + read existing AGENTS.md and CLAUDE.md\", status: \"pending\", priority: \"high\" },\n  { id: \"scoring\", content: \"Score directories, determine locations + monorepo packages\", status: \"pending\", priority: \"high\" },\n  { id: \"generate\", content: \"Generate AGENTS.md + CLAUDE.md files (root + subdirs)\", status: \"pending\", priority: \"high\" },\n  { id: \"review\", content: \"Deduplicate, validate, trim, ensure file pairs\", status: \"pending\", priority: \"medium\" }\n])\n```\n\u003C\u002Fcritical>\n\n---\n\n## Phase 1: Discovery + Analysis (Concurrent)\n\n**Mark \"discovery\" as in_progress.**\n\n### Fire Background Explore Agents IMMEDIATELY\n\nDon't wait—these run async while main session works.\n\n```\n\u002F\u002F Fire all at once, collect results later\ntask(subagent_type=\"explore\", load_skills=[], description=\"Explore project structure\", run_in_background=true, prompt=\"Project structure: PREDICT standard patterns for detected language → REPORT deviations only\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Find entry points\", run_in_background=true, prompt=\"Entry points: FIND main files → REPORT non-standard organization\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Find conventions\", run_in_background=true, prompt=\"Conventions: FIND config files (.eslintrc, pyproject.toml, .editorconfig) → REPORT project-specific rules\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Find anti-patterns\", run_in_background=true, prompt=\"Anti-patterns: FIND 'DO NOT', 'NEVER', 'ALWAYS', 'DEPRECATED' comments → LIST forbidden patterns\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Explore build\u002FCI\", run_in_background=true, prompt=\"Build\u002FCI: FIND .github\u002Fworkflows, Makefile → REPORT non-standard patterns\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Find test patterns\", run_in_background=true, prompt=\"Test patterns: FIND test configs, test structure → REPORT unique conventions\")\n```\n\n\u003Cdynamic-agents>\n**DYNAMIC AGENT SPAWNING**: After bash analysis, spawn ADDITIONAL explore agents based on project scale:\n\n| Factor                       | Threshold | Additional Agents          |\n| ---------------------------- | --------- | -------------------------- |\n| **Total files**              | >100      | +1 per 100 files           |\n| **Total lines**              | >10k      | +1 per 10k lines           |\n| **Directory depth**          | ≥4        | +2 for deep exploration    |\n| **Large files (>500 lines)** | >10 files | +1 for complexity hotspots |\n| **Monorepo**                 | detected  | +1 per package\u002Fworkspace   |\n| **Multiple languages**       | >1        | +1 per language            |\n\n```bash\n# Measure project scale first\ntotal_files=$(find . -type f -not -path '*\u002Fnode_modules\u002F*' -not -path '*\u002F.git\u002F*' | wc -l)\ntotal_lines=$(find . -type f \\( -name \"*.ts\" -o -name \"*.py\" -o -name \"*.go\" \\) -not -path '*\u002Fnode_modules\u002F*' -exec wc -l {} + 2>\u002Fdev\u002Fnull | tail -1 | awk '{print $1}')\nlarge_files=$(find . -type f \\( -name \"*.ts\" -o -name \"*.py\" \\) -not -path '*\u002Fnode_modules\u002F*' -exec wc -l {} + 2>\u002Fdev\u002Fnull | awk '$1 > 500 {count++} END {print count+0}')\nmax_depth=$(find . -type d -not -path '*\u002Fnode_modules\u002F*' -not -path '*\u002F.git\u002F*' | awk -F\u002F '{print NF}' | sort -rn | head -1)\n```\n\nExample spawning:\n\n```\n\u002F\u002F 500 files, 50k lines, depth 6, 15 large files → spawn 5+5+2+1 = 13 additional agents\ntask(subagent_type=\"explore\", load_skills=[], description=\"Analyze large files\", run_in_background=true, prompt=\"Large file analysis: FIND files >500 lines, REPORT complexity hotspots\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Explore deep modules\", run_in_background=true, prompt=\"Deep modules at depth 4+: FIND hidden patterns, internal conventions\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Find shared utilities\", run_in_background=true, prompt=\"Cross-cutting concerns: FIND shared utilities across directories\")\n\u002F\u002F ... more based on calculation\n```\n\n\u003C\u002Fdynamic-agents>\n\n### Main Session: Concurrent Analysis\n\n**While background agents run**, main session does:\n\n#### 1. Bash Structural Analysis\n\n```bash\n# Directory depth + file counts\nfind . -type d -not -path '*\u002F\\.*' -not -path '*\u002Fnode_modules\u002F*' -not -path '*\u002Fvenv\u002F*' -not -path '*\u002Fdist\u002F*' -not -path '*\u002Fbuild\u002F*' | awk -F\u002F '{print NF-1}' | sort -n | uniq -c\n\n# Files per directory (top 30)\nfind . -type f -not -path '*\u002F\\.*' -not -path '*\u002Fnode_modules\u002F*' | sed 's|\u002F[^\u002F]*$||' | sort | uniq -c | sort -rn | head -30\n\n# Code concentration by extension\nfind . -type f \\( -name \"*.py\" -o -name \"*.ts\" -o -name \"*.tsx\" -o -name \"*.js\" -o -name \"*.go\" -o -name \"*.rs\" \\) -not -path '*\u002Fnode_modules\u002F*' | sed 's|\u002F[^\u002F]*$||' | sort | uniq -c | sort -rn | head -20\n\n# Existing AGENTS.md \u002F CLAUDE.md\nfind . -type f \\( -name \"AGENTS.md\" -o -name \"CLAUDE.md\" \\) -not -path '*\u002Fnode_modules\u002F*' 2>\u002Fdev\u002Fnull\n\n# Monorepo detection (package directories)\nfind . \\( -name \"package.json\" -o -name \"pyproject.toml\" -o -name \"Cargo.toml\" -o -name \"go.mod\" \\) -not -path '*\u002Fnode_modules\u002F*' -not -path '*\u002F.git\u002F*' | sed 's|\u002F[^\u002F]*$||' | sort | uniq\n```\n\n#### 2. Read Existing AGENTS.md and CLAUDE.md\n\nFor each directory where either AGENTS.md or CLAUDE.md exists:\n\n```\nagents_exists = file exists at {dir}\u002FAGENTS.md\nclaude_exists = file exists at {dir}\u002FCLAUDE.md\n\nIf agents_exists AND claude_exists:\n  Read both files\n  Merge their contents into EXISTING_AGENTS map for that directory\nElse if agents_exists AND NOT claude_exists:\n  Read AGENTS.md\n  Create symlink: ln -s AGENTS.md CLAUDE.md (or ln -s CLAUDE.md AGENTS.md if you prefer; standard: ln -s AGENTS.md CLAUDE.md)\nElse if claude_exists AND NOT agents_exists:\n  Read CLAUDE.md\n  Create symlink: ln -s CLAUDE.md AGENTS.md\n```\n\n\u003Ccritical>\nIf `--create-new`: Read all existing first (preserve context) → delete all AGENTS.md and CLAUDE.md + their symlinks → regenerate.\n\u003C\u002Fcritical>\n\n#### 3. LSP Codemap (if available)\n\n```\nLspServers()  # Check availability\n\n# Entry points (parallel)\nLspDocumentSymbols(filePath=\"src\u002Findex.ts\")\nLspDocumentSymbols(filePath=\"main.py\")\n\n# Key symbols (parallel)\nLspWorkspaceSymbols(filePath=\".\", query=\"class\")\nLspWorkspaceSymbols(filePath=\".\", query=\"interface\")\nLspWorkspaceSymbols(filePath=\".\", query=\"function\")\n\n# Centrality for top exports\nLspFindReferences(filePath=\"...\", line=X, character=Y)\n```\n\n**LSP Fallback**: If unavailable, rely on explore agents + AST-grep.\n\n### Collect Background Results\n\n```\n\u002F\u002F After main session analysis done, collect all task results\nfor each task_id: background_output(task_id=\"...\")\n```\n\n**Merge: bash + LSP + existing + explore findings. Mark \"discovery\" as completed.**\n\n---\n\n## Phase 2: Scoring & Location Decision\n\n**Mark \"scoring\" as in_progress.**\n\n### Scoring Matrix\n\n| Factor               | Weight | High Threshold           | Source  |\n| -------------------- | ------ | ------------------------ | ------- |\n| File count           | 3x     | >20                      | bash    |\n| Subdir count         | 2x     | >5                       | bash    |\n| Code ratio           | 2x     | >70%                     | bash    |\n| Unique patterns      | 1x     | Has own config           | explore |\n| Module boundary      | 2x     | Has index.ts\u002F**init**.py | bash    |\n| Symbol density       | 2x     | >30 symbols              | LSP     |\n| Export count         | 2x     | >10 exports              | LSP     |\n| Reference centrality | 3x     | >20 refs                 | LSP     |\n\n### Monorepo Rule\n\n**Every monorepo package directory MUST have an AGENTS.md + CLAUDE.md pair, regardless of score.**\n\nDetect packages via:\n\n- `package.json` in subdirectories (Node\u002FYarn\u002Fnpm workspaces, pnpm)\n- `pyproject.toml` with `[tool.poetry]` or `[project]`\n- `Cargo.toml` (Rust workspace member)\n- `go.mod` (Go module)\n\nAdd all unique package directories to `AGENTS_LOCATIONS` with `type: \"package\"`.\n\n### Decision Rules\n\n| Score                | Action                       |\n| -------------------- | ---------------------------- |\n| **Root (.)**         | ALWAYS create                |\n| **Monorepo package** | ALWAYS create                |\n| **>15**              | Create AGENTS.md + CLAUDE.md |\n| **8-15**             | Create if distinct domain    |\n| **\u003C8**               | Skip (parent covers)         |\n\n### Output\n\n```\nAGENTS_LOCATIONS = [\n  { path: \".\", type: \"root\" },\n  { path: \"packages\u002Fcore\", type: \"package\", score: null, reason: \"monorepo package\" },\n  { path: \"src\u002Fhooks\", score: 18, reason: \"high complexity\" },\n  { path: \"src\u002Fapi\", score: 12, reason: \"distinct domain\" }\n]\n```\n\n**Mark \"scoring\" as completed.**\n\n---\n\n## Phase 3: Generate AGENTS.md & CLAUDE.md\n\n**Mark \"generate\" as in_progress.**\n\n\u003Ccritical>\n**File Writing Rule**:\n- If AGENTS.md already exists at the target path → use `Edit` tool.\n- If AGENTS.md does NOT exist → use `Write` tool.\n- NEVER use Write to overwrite an existing file. ALWAYS check existence first via `Read` or discovery results.\n- After writing AGENTS.md, ensure CLAUDE.md exists in the same directory. If missing, create it as a symlink to AGENTS.md.\n- If both files already exist and both are regular files (not symlinks), merge their content mentally and then use `Edit` to update both to the merged content.\n\u003C\u002Fcritical>\n\n### Pairing Rules Per Directory\n\nFor every location in `AGENTS_LOCATIONS`:\n\n1. **Generate AGENTS.md** content using the templates below.\n2. **Ensure CLAUDE.md exists** in the same directory:\n    - If **neither exists**: Write AGENTS.md, then `ln -s AGENTS.md CLAUDE.md`\n    - If **only AGENTS.md exists**: `ln -s AGENTS.md CLAUDE.md`\n    - If **only CLAUDE.md exists**: `mv CLAUDE.md AGENTS.md`, then `ln -s AGENTS.md CLAUDE.md`\n    - If **both exist as regular files**: Merge content from both, then use `Edit` to update both to the merged content.\n\n**Preferred approach**: Write AGENTS.md as the canonical file, then `ln -s AGENTS.md CLAUDE.md` in all cases where no conflict exists.\n\n### Root AGENTS.md (Full Treatment)\n\n```markdown\n# PROJECT KNOWLEDGE BASE\n\n**Generated:** {TIMESTAMP}\n**Commit:** {SHORT_SHA}\n**Branch:** {BRANCH}\n\n## OVERVIEW\n\n{1-2 sentences: what + core stack}\n\n## STRUCTURE\n```\n\n{root}\u002F\n├── {dir}\u002F # {non-obvious purpose only}\n└── {entry}\n\n```\n## WHERE TO LOOK\n| Task | Location | Notes |\n|------|----------|-------|\n\n## CODE MAP\n{From LSP - skip if unavailable or project \u003C10 files}\n\n| Symbol | Type | Location | Refs | Role |\n|--------|------|----------|------|------|\n\n## CONVENTIONS\n{ONLY deviations from standard}\n\n## ANTI-PATTERNS (THIS PROJECT)\n{Explicitly forbidden here}\n\n## UNIQUE STYLES\n{Project-specific}\n\n## COMMANDS\n```\n\n{dev\u002Ftest\u002Fbuild}\n\n```\n## NOTES\n{Gotchas}\n```\n\n**Quality gates**: 50-150 lines, no generic advice, no obvious info.\n\n### Monorepo Package AGENTS.md\n\nSame structure as root but scoped to the package:\n\n- Mention package name and its role in the monorepo\n- Link to root AGENTS.md for global conventions\n- 30-80 lines max\n\n### Subdirectory AGENTS.md (Parallel)\n\nLaunch writing tasks for each location:\n\n```\nfor loc in AGENTS_LOCATIONS (except root):\n  task(category=\"writing\", load_skills=[], run_in_background=false, description=\"Generate AGENTS.md\", prompt=`\n    Generate AGENTS.md for: ${loc.path}\n    - Type: ${loc.type} (package | subdir)\n    - Reason: ${loc.reason}\n    - 30-80 lines max\n    - NEVER repeat parent content\n    - Sections: OVERVIEW (1 line), STRUCTURE (if >5 subdirs), WHERE TO LOOK, CONVENTIONS (if different), ANTI-PATTERNS\n    If type is \"package\", include the package's role in the monorepo and link to root conventions.\n  `)\n```\n\nAfter each AGENTS.md is written, run the pairing check to ensure CLAUDE.md exists (create symlink if missing).\n\n**Wait for all. Mark \"generate\" as completed.**\n\n---\n\n## Phase 4: Review & Deduplicate\n\n**Mark \"review\" as in_progress.**\n\nFor each generated file:\n\n- Remove generic advice\n- Remove parent duplicates\n- Trim to size limits\n- Verify telegraphic style\n- **Verify every AGENTS.md has a paired CLAUDE.md in the same directory**\n- Fix any missing symlinks\n\n**Mark \"review\" as completed.**\n\n---\n\n## Final Report\n\n```\n=== init-deep Complete ===\n\nMode: {update | create-new}\n\nFiles:\n  [OK] .\u002FAGENTS.md (root, {N} lines)\n  [OK] .\u002FCLAUDE.md → symlinked to .\u002FAGENTS.md\n  [OK] .\u002Fpackages\u002Fcore\u002FAGENTS.md ({N} lines)\n  [OK] .\u002Fpackages\u002Fcore\u002FCLAUDE.md → symlinked to .\u002FAGENTS.md\n  [OK] .\u002Fsrc\u002Fhooks\u002FAGENTS.md ({N} lines)\n  [OK] .\u002Fsrc\u002Fhooks\u002FCLAUDE.md → symlinked to .\u002FAGENTS.md\n\nDirs Analyzed: {N}\nAGENTS.md Created: {N}\nCLAUDE.md Created: {N}\nPairs Ensured: {N}\n\nHierarchy:\n  .\u002FAGENTS.md\n  ├── packages\u002Fcore\u002FAGENTS.md\n  └── src\u002Fhooks\u002FAGENTS.md\n```\n\n---\n\n## Anti-Patterns\n\n- **Static agent count**: MUST vary agents based on project size\u002Fdepth\n- **Sequential execution**: MUST parallel (explore + LSP concurrent)\n- **Ignoring existing**: ALWAYS read existing first, even with --create-new\n- **Over-documenting**: Not every dir needs AGENTS.md (except monorepo packages)\n- **Redundancy**: Child never repeats parent\n- **Generic content**: Remove anything that applies to ALL projects\n- **Verbose style**: Telegraphic or die\n- **Orphan files**: NEVER leave AGENTS.md without CLAUDE.md in the same directory\n","# \u002Finit-deep\n\nGenerate hierarchical AGENTS.md files. Ensure every AGENTS.md has a paired CLAUDE.md (and vice versa) via symlinks. Root + complexity-scored subdirectories + all monorepo packages.\n\n## Usage\n\n```\n\u002Finit-deep                      # Update mode: modify existing + create new where warranted\n\u002Finit-deep --create-new         # Read existing → remove all → regenerate from scratch\n\u002Finit-deep --max-depth=2        # Limit directory depth (default: 3)\n```\n\n---\n\n## Workflow (High-Level)\n\n1. **Discovery + Analysis** (concurrent)\n    - Fire background explore agents immediately\n    - Main session: bash structure + LSP codemap + read existing AGENTS.md and CLAUDE.md\n2. **Score & Decide** - Determine AGENTS.md\u002FCLAUDE.md locations from merged findings\n3. **Generate** - Root first, then subdirs in parallel\n4. **Review** - Deduplicate, trim, validate, ensure pairs\n\n\u003Ccritical>\n**TodoWrite ALL phases. Mark in_progress → completed in real-time.**\n```\nTodoWrite([\n  { id: \"discovery\", content: \"Fire explore agents + LSP codemap + read existing AGENTS.md and CLAUDE.md\", status: \"pending\", priority: \"high\" },\n  { id: \"scoring\", content: \"Score directories, determine locations + monorepo packages\", status: \"pending\", priority: \"high\" },\n  { id: \"generate\", content: \"Generate AGENTS.md + CLAUDE.md files (root + subdirs)\", status: \"pending\", priority: \"high\" },\n  { id: \"review\", content: \"Deduplicate, validate, trim, ensure file pairs\", status: \"pending\", priority: \"medium\" }\n])\n```\n\u003C\u002Fcritical>\n\n---\n\n## Phase 1: Discovery + Analysis (Concurrent)\n\n**Mark \"discovery\" as in_progress.**\n\n### Fire Background Explore Agents IMMEDIATELY\n\nDon't wait—these run async while main session works.\n\n```\n\u002F\u002F Fire all at once, collect results later\ntask(subagent_type=\"explore\", load_skills=[], description=\"Explore project structure\", run_in_background=true, prompt=\"Project structure: PREDICT standard patterns for detected language → REPORT deviations only\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Find entry points\", run_in_background=true, prompt=\"Entry points: FIND main files → REPORT non-standard organization\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Find conventions\", run_in_background=true, prompt=\"Conventions: FIND config files (.eslintrc, pyproject.toml, .editorconfig) → REPORT project-specific rules\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Find anti-patterns\", run_in_background=true, prompt=\"Anti-patterns: FIND 'DO NOT', 'NEVER', 'ALWAYS', 'DEPRECATED' comments → LIST forbidden patterns\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Explore build\u002FCI\", run_in_background=true, prompt=\"Build\u002FCI: FIND .github\u002Fworkflows, Makefile → REPORT non-standard patterns\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Find test patterns\", run_in_background=true, prompt=\"Test patterns: FIND test configs, test structure → REPORT unique conventions\")\n```\n\n\u003Cdynamic-agents>\n**DYNAMIC AGENT SPAWNING**: After bash analysis, spawn ADDITIONAL explore agents based on project scale:\n\n| Factor                       | Threshold | Additional Agents          |\n| ---------------------------- | --------- | -------------------------- |\n| **Total files**              | >100      | +1 per 100 files           |\n| **Total lines**              | >10k      | +1 per 10k lines           |\n| **Directory depth**          | ≥4        | +2 for deep exploration    |\n| **Large files (>500 lines)** | >10 files | +1 for complexity hotspots |\n| **Monorepo**                 | detected  | +1 per package\u002Fworkspace   |\n| **Multiple languages**       | >1        | +1 per language            |\n\n```bash\n# Measure project scale first\ntotal_files=$(find . -type f -not -path '*\u002Fnode_modules\u002F*' -not -path '*\u002F.git\u002F*' | wc -l)\ntotal_lines=$(find . -type f \\( -name \"*.ts\" -o -name \"*.py\" -o -name \"*.go\" \\) -not -path '*\u002Fnode_modules\u002F*' -exec wc -l {} + 2>\u002Fdev\u002Fnull | tail -1 | awk '{print $1}')\nlarge_files=$(find . -type f \\( -name \"*.ts\" -o -name \"*.py\" \\) -not -path '*\u002Fnode_modules\u002F*' -exec wc -l {} + 2>\u002Fdev\u002Fnull | awk '$1 > 500 {count++} END {print count+0}')\nmax_depth=$(find . -type d -not -path '*\u002Fnode_modules\u002F*' -not -path '*\u002F.git\u002F*' | awk -F\u002F '{print NF}' | sort -rn | head -1)\n```\n\nExample spawning:\n\n```\n\u002F\u002F 500 files, 50k lines, depth 6, 15 large files → spawn 5+5+2+1 = 13 additional agents\ntask(subagent_type=\"explore\", load_skills=[], description=\"Analyze large files\", run_in_background=true, prompt=\"Large file analysis: FIND files >500 lines, REPORT complexity hotspots\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Explore deep modules\", run_in_background=true, prompt=\"Deep modules at depth 4+: FIND hidden patterns, internal conventions\")\ntask(subagent_type=\"explore\", load_skills=[], description=\"Find shared utilities\", run_in_background=true, prompt=\"Cross-cutting concerns: FIND shared utilities across directories\")\n\u002F\u002F ... more based on calculation\n```\n\n\u003C\u002Fdynamic-agents>\n\n### Main Session: Concurrent Analysis\n\n**While background agents run**, main session does:\n\n#### 1. Bash Structural Analysis\n\n```bash\n# Directory depth + file counts\nfind . -type d -not -path '*\u002F\\.*' -not -path '*\u002Fnode_modules\u002F*' -not -path '*\u002Fvenv\u002F*' -not -path '*\u002Fdist\u002F*' -not -path '*\u002Fbuild\u002F*' | awk -F\u002F '{print NF-1}' | sort -n | uniq -c\n\n# Files per directory (top 30)\nfind . -type f -not -path '*\u002F\\.*' -not -path '*\u002Fnode_modules\u002F*' | sed 's|\u002F[^\u002F]*$||' | sort | uniq -c | sort -rn | head -30\n\n# Code concentration by extension\nfind . -type f \\( -name \"*.py\" -o -name \"*.ts\" -o -name \"*.tsx\" -o -name \"*.js\" -o -name \"*.go\" -o -name \"*.rs\" \\) -not -path '*\u002Fnode_modules\u002F*' | sed 's|\u002F[^\u002F]*$||' | sort | uniq -c | sort -rn | head -20\n\n# Existing AGENTS.md \u002F CLAUDE.md\nfind . -type f \\( -name \"AGENTS.md\" -o -name \"CLAUDE.md\" \\) -not -path '*\u002Fnode_modules\u002F*' 2>\u002Fdev\u002Fnull\n\n# Monorepo detection (package directories)\nfind . \\( -name \"package.json\" -o -name \"pyproject.toml\" -o -name \"Cargo.toml\" -o -name \"go.mod\" \\) -not -path '*\u002Fnode_modules\u002F*' -not -path '*\u002F.git\u002F*' | sed 's|\u002F[^\u002F]*$||' | sort | uniq\n```\n\n#### 2. Read Existing AGENTS.md and CLAUDE.md\n\nFor each directory where either AGENTS.md or CLAUDE.md exists:\n\n```\nagents_exists = file exists at {dir}\u002FAGENTS.md\nclaude_exists = file exists at {dir}\u002FCLAUDE.md\n\nIf agents_exists AND claude_exists:\n  Read both files\n  Merge their contents into EXISTING_AGENTS map for that directory\nElse if agents_exists AND NOT claude_exists:\n  Read AGENTS.md\n  Create symlink: ln -s AGENTS.md CLAUDE.md (or ln -s CLAUDE.md AGENTS.md if you prefer; standard: ln -s AGENTS.md CLAUDE.md)\nElse if claude_exists AND NOT agents_exists:\n  Read CLAUDE.md\n  Create symlink: ln -s CLAUDE.md AGENTS.md\n```\n\n\u003Ccritical>\nIf `--create-new`: Read all existing first (preserve context) → delete all AGENTS.md and CLAUDE.md + their symlinks → regenerate.\n\u003C\u002Fcritical>\n\n#### 3. LSP Codemap (if available)\n\n```\nLspServers()  # Check availability\n\n# Entry points (parallel)\nLspDocumentSymbols(filePath=\"src\u002Findex.ts\")\nLspDocumentSymbols(filePath=\"main.py\")\n\n# Key symbols (parallel)\nLspWorkspaceSymbols(filePath=\".\", query=\"class\")\nLspWorkspaceSymbols(filePath=\".\", query=\"interface\")\nLspWorkspaceSymbols(filePath=\".\", query=\"function\")\n\n# Centrality for top exports\nLspFindReferences(filePath=\"...\", line=X, character=Y)\n```\n\n**LSP Fallback**: If unavailable, rely on explore agents + AST-grep.\n\n### Collect Background Results\n\n```\n\u002F\u002F After main session analysis done, collect all task results\nfor each task_id: background_output(task_id=\"...\")\n```\n\n**Merge: bash + LSP + existing + explore findings. Mark \"discovery\" as completed.**\n\n---\n\n## Phase 2: Scoring & Location Decision\n\n**Mark \"scoring\" as in_progress.**\n\n### Scoring Matrix\n\n| Factor               | Weight | High Threshold           | Source  |\n| -------------------- | ------ | ------------------------ | ------- |\n| File count           | 3x     | >20                      | bash    |\n| Subdir count         | 2x     | >5                       | bash    |\n| Code ratio           | 2x     | >70%                     | bash    |\n| Unique patterns      | 1x     | Has own config           | explore |\n| Module boundary      | 2x     | Has index.ts\u002F**init**.py | bash    |\n| Symbol density       | 2x     | >30 symbols              | LSP     |\n| Export count         | 2x     | >10 exports              | LSP     |\n| Reference centrality | 3x     | >20 refs                 | LSP     |\n\n### Monorepo Rule\n\n**Every monorepo package directory MUST have an AGENTS.md + CLAUDE.md pair, regardless of score.**\n\nDetect packages via:\n\n- `package.json` in subdirectories (Node\u002FYarn\u002Fnpm workspaces, pnpm)\n- `pyproject.toml` with `[tool.poetry]` or `[project]`\n- `Cargo.toml` (Rust workspace member)\n- `go.mod` (Go module)\n\nAdd all unique package directories to `AGENTS_LOCATIONS` with `type: \"package\"`.\n\n### Decision Rules\n\n| Score                | Action                       |\n| -------------------- | ---------------------------- |\n| **Root (.)**         | ALWAYS create                |\n| **Monorepo package** | ALWAYS create                |\n| **>15**              | Create AGENTS.md + CLAUDE.md |\n| **8-15**             | Create if distinct domain    |\n| **\u003C8**               | Skip (parent covers)         |\n\n### Output\n\n```\nAGENTS_LOCATIONS = [\n  { path: \".\", type: \"root\" },\n  { path: \"packages\u002Fcore\", type: \"package\", score: null, reason: \"monorepo package\" },\n  { path: \"src\u002Fhooks\", score: 18, reason: \"high complexity\" },\n  { path: \"src\u002Fapi\", score: 12, reason: \"distinct domain\" }\n]\n```\n\n**Mark \"scoring\" as completed.**\n\n---\n\n## Phase 3: Generate AGENTS.md & CLAUDE.md\n\n**Mark \"generate\" as in_progress.**\n\n\u003Ccritical>\n**File Writing Rule**:\n- If AGENTS.md already exists at the target path → use `Edit` tool.\n- If AGENTS.md does NOT exist → use `Write` tool.\n- NEVER use Write to overwrite an existing file. ALWAYS check existence first via `Read` or discovery results.\n- After writing AGENTS.md, ensure CLAUDE.md exists in the same directory. If missing, create it as a symlink to AGENTS.md.\n- If both files already exist and both are regular files (not symlinks), merge their content mentally and then use `Edit` to update both to the merged content.\n\u003C\u002Fcritical>\n\n### Pairing Rules Per Directory\n\nFor every location in `AGENTS_LOCATIONS`:\n\n1. **Generate AGENTS.md** content using the templates below.\n2. **Ensure CLAUDE.md exists** in the same directory:\n    - If **neither exists**: Write AGENTS.md, then `ln -s AGENTS.md CLAUDE.md`\n    - If **only AGENTS.md exists**: `ln -s AGENTS.md CLAUDE.md`\n    - If **only CLAUDE.md exists**: `mv CLAUDE.md AGENTS.md`, then `ln -s AGENTS.md CLAUDE.md`\n    - If **both exist as regular files**: Merge content from both, then use `Edit` to update both to the merged content.\n\n**Preferred approach**: Write AGENTS.md as the canonical file, then `ln -s AGENTS.md CLAUDE.md` in all cases where no conflict exists.\n\n### Root AGENTS.md (Full Treatment)\n\n```markdown\n# PROJECT KNOWLEDGE BASE\n\n**Generated:** {TIMESTAMP}\n**Commit:** {SHORT_SHA}\n**Branch:** {BRANCH}\n\n## OVERVIEW\n\n{1-2 sentences: what + core stack}\n\n## STRUCTURE\n```\n\n{root}\u002F\n├── {dir}\u002F # {non-obvious purpose only}\n└── {entry}\n\n```\n## WHERE TO LOOK\n| Task | Location | Notes |\n|------|----------|-------|\n\n## CODE MAP\n{From LSP - skip if unavailable or project \u003C10 files}\n\n| Symbol | Type | Location | Refs | Role |\n|--------|------|----------|------|------|\n\n## CONVENTIONS\n{ONLY deviations from standard}\n\n## ANTI-PATTERNS (THIS PROJECT)\n{Explicitly forbidden here}\n\n## UNIQUE STYLES\n{Project-specific}\n\n## COMMANDS\n```\n\n{dev\u002Ftest\u002Fbuild}\n\n```\n## NOTES\n{Gotchas}\n```\n\n**Quality gates**: 50-150 lines, no generic advice, no obvious info.\n\n### Monorepo Package AGENTS.md\n\nSame structure as root but scoped to the package:\n\n- Mention package name and its role in the monorepo\n- Link to root AGENTS.md for global conventions\n- 30-80 lines max\n\n### Subdirectory AGENTS.md (Parallel)\n\nLaunch writing tasks for each location:\n\n```\nfor loc in AGENTS_LOCATIONS (except root):\n  task(category=\"writing\", load_skills=[], run_in_background=false, description=\"Generate AGENTS.md\", prompt=`\n    Generate AGENTS.md for: ${loc.path}\n    - Type: ${loc.type} (package | subdir)\n    - Reason: ${loc.reason}\n    - 30-80 lines max\n    - NEVER repeat parent content\n    - Sections: OVERVIEW (1 line), STRUCTURE (if >5 subdirs), WHERE TO LOOK, CONVENTIONS (if different), ANTI-PATTERNS\n    If type is \"package\", include the package's role in the monorepo and link to root conventions.\n  `)\n```\n\nAfter each AGENTS.md is written, run the pairing check to ensure CLAUDE.md exists (create symlink if missing).\n\n**Wait for all. Mark \"generate\" as completed.**\n\n---\n\n## Phase 4: Review & Deduplicate\n\n**Mark \"review\" as in_progress.**\n\nFor each generated file:\n\n- Remove generic advice\n- Remove parent duplicates\n- Trim to size limits\n- Verify telegraphic style\n- **Verify every AGENTS.md has a paired CLAUDE.md in the same directory**\n- Fix any missing symlinks\n\n**Mark \"review\" as completed.**\n\n---\n\n## Final Report\n\n```\n=== init-deep Complete ===\n\nMode: {update | create-new}\n\nFiles:\n  [OK] .\u002FAGENTS.md (root, {N} lines)\n  [OK] .\u002FCLAUDE.md → symlinked to .\u002FAGENTS.md\n  [OK] .\u002Fpackages\u002Fcore\u002FAGENTS.md ({N} lines)\n  [OK] .\u002Fpackages\u002Fcore\u002FCLAUDE.md → symlinked to .\u002FAGENTS.md\n  [OK] .\u002Fsrc\u002Fhooks\u002FAGENTS.md ({N} lines)\n  [OK] .\u002Fsrc\u002Fhooks\u002FCLAUDE.md → symlinked to .\u002FAGENTS.md\n\nDirs Analyzed: {N}\nAGENTS.md Created: {N}\nCLAUDE.md Created: {N}\nPairs Ensured: {N}\n\nHierarchy:\n  .\u002FAGENTS.md\n  ├── packages\u002Fcore\u002FAGENTS.md\n  └── src\u002Fhooks\u002FAGENTS.md\n```\n\n---\n\n## Anti-Patterns\n\n- **Static agent count**: MUST vary agents based on project size\u002Fdepth\n- **Sequential execution**: MUST parallel (explore + LSP concurrent)\n- **Ignoring existing**: ALWAYS read existing first, even with --create-new\n- **Over-documenting**: Not every dir needs AGENTS.md (except monorepo packages)\n- **Redundancy**: Child never repeats parent\n- **Generic content**: Remove anything that applies to ALL projects\n- **Verbose style**: Telegraphic or die\n- **Orphan files**: NEVER leave AGENTS.md without CLAUDE.md in the same directory\n",{"name":5,"description":7},"main","2a846f29fb144c9e738f1c79a4a9f17c2f5d0c19",".claude\u002Fskills\u002Finit-deep",19,"https:\u002F\u002Fgithub.com\u002FAkaraChen\u002Faghub","https:\u002F\u002Faghub.akr.moe","https:\u002F\u002Fgithub.com\u002FAkaraChen","https:\u002F\u002Fakr.moe","button painter, string concatenator, log alchemist.\r\n\r\nNo slop, no lag.","2026-11-10 06:35:07",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add AkaraChen\u002Faghub --skill init-deep",{"tool":56,"command":57},"bunx","bunx skills add AkaraChen\u002Faghub --skill init-deep",{"tool":59,"command":60},"pnpm","pnpm dlx skills add AkaraChen\u002Faghub --skill init-deep","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAkaraChen\u002Faghub\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Finit-deep\u002FSKILL.md",true,[],[65,77,88,106,116,124],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":35},"01M6E1C5XRWJGK1FTMBYBP72EP","vercel-react-best-practices","Vercel React Best Practices","https:\u002F\u002Fgithub.com\u002FAkaraChen\u002Faghub\u002Fblob\u002Fmain\u002Ffixtures\u002F.agents\u002Fskills\u002Fvercel-react-best-practices\u002FSKILL.md",[],[72,73,74,75,76],"vercel","react best practices","best practices","vercel react best practices","react",{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":35},"01M6E1BY84HFA0FF0W0APPNYH6","typeset","Improves typography by fixing font choices, hierarchy, sizing, weight, and readability so text feels intentional. Use when the user mentions fonts, type, readability, text hierarchy, sizing looks off, or wants more polished, intentional typography.","https:\u002F\u002Fgithub.com\u002FAkaraChen\u002Faghub\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ftypeset\u002FSKILL.md",[],[79,84,21,28,85,86,87],"text","typography","readability","type",{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":35},"01M6E1BTSRZMPTXVD95MB7FA01","teach-impeccable","One-time setup that gathers design context for your project and saves it to your AI config file. Run once to establish persistent design guidelines.","https:\u002F\u002Fgithub.com\u002FAkaraChen\u002Faghub\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fteach-impeccable\u002FSKILL.md",[],[95,96,97,98,99,100,22,101,102,103,104,31,105],"teach","teach impeccable","impeccable","ai config","context","time","design","config","setup","guidelines","file",{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":35},"01M6E1BQH59R5H8XA4MH3S083N","quieter","Tones down visually aggressive or overstimulating designs, reducing intensity while preserving quality. Use when the user mentions too bold, too loud, overwhelming, aggressive, garish, or wants a calmer, more refined aesthetic.","https:\u002F\u002Fgithub.com\u002FAkaraChen\u002Faghub\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fquieter\u002FSKILL.md",[],[108,113,21,28,114,115],"quality","aesthetic","intensity",{"skillNo":117,"name":118,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":35},"01M6E1BMJ7PNFPXD8SRCQ6WH1S","project-form-patterns","https:\u002F\u002Fgithub.com\u002FAkaraChen\u002Faghub\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fproject-form-patterns\u002FSKILL.md",[],[122,22,123],"project form patterns","patterns",{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":35},"01M6E1BHEDVTPKC1KS7A7B0VGZ","polish","Performs a final quality pass fixing alignment, spacing, consistency, and micro-detail issues before shipping. Use when the user mentions polish, finishing touches, pre-launch review, something looks off, or wants to go from good to great.","https:\u002F\u002Fgithub.com\u002FAkaraChen\u002Faghub\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpolish\u002FSKILL.md",[],[126,113,131,132,133,134,135,136,137,28,138,139,21],"micro","issues","shipping","launch","go","alignment","good","detail","review"]