{"id":"llm-wiki","name":"llm-wiki","summary":"どんなコードベースでも構造化されたLLM生成のウィキを構築し、維持してください。ユーザーがコードベースの分析・理解・ドキュメント化、コードウィキの作成、ソースからプロジェクトドキュメントを作成、既存の.llm-wikiの更新を求めたときに使います。","body":"# LLM Wiki for Codebases\n\nBuild a persistent, interlinked markdown wiki that captures the architecture, modules, patterns, and APIs of a codebase. The wiki lives in `.llm-wiki/` at the project root. Humans curate and direct; the LLM handles all bookkeeping.\n\nBased on [Andrej Karpathy's LLM Wiki pattern](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f): raw sources are \"compiled\" into a structured wiki that compounds over time.\n\n## Mode Detection\n\nDetermine the mode based on current state:\n\n- **No `.llm-wiki/` directory exists** -> Full Build mode\n- **`.llm-wiki/` exists** -> Update mode (diff and refresh)\n\n## Full Build Workflow\n\n### Phase 1: Reconnaissance\n\n1. Read top-level files: README, package.json/Cargo.toml/go.mod/pyproject.toml/build.gradle etc.\n2. Run `find` or Glob to map the directory tree (ignore node_modules, .git, vendor, dist, build, __pycache__, .venv)\n3. Identify: language(s), framework(s), build system, entry point(s), test framework\n4. Count files per directory to gauge module boundaries\n5. Read CLAUDE.md / AGENTS.md / .cursor/rules if present - they contain valuable architectural context\n\nRecord findings in `.llm-wiki/_schema.md` (see references/wiki-schema.md for format).\n\n### Phase 2: Skeleton\n\nCreate the directory structure:\n\n```\n.llm-wiki/\n  _schema.md          # Wiki conventions and project metadata\n  _index.md           # Content-oriented catalog by category\n  _log.md             # Chronological build/update log\n  architecture/       # High-level design docs\n  modules/            # Per-module deep dives\n  concepts/           # Cross-cutting concepts (auth, caching, error handling...)\n  apis/               # API surface docs (REST endpoints, CLI commands, exported functions)\n  guides/             # How-to guides (setup, deployment, testing)\n```\n\n### Phase 3: Core Articles\n\nWrite articles in priority order. See references/article-templates.md for templates.\n\n**Priority 1 - Architecture:**\n- `architecture/overview.md` - System architecture, component diagram (ASCII), tech stack\n- `architecture/data-flow.md` - How data flows through the system\n- `architecture/directory-structure.md` - Annotated directory tree\n\n**Priority 2 - Modules:**\n- One `modules/<name>.md` per major module/package/directory\n- Cover: purpose, key files, public interface, internal patterns, dependencies\n\n**Priority 3 - Concepts:**\n- Cross-cutting concerns that span modules (auth, logging, error handling, state management, config)\n- One `concepts/<name>.md` per concept\n\n**Priority 4 - APIs:**\n- External-facing API surfaces (REST routes, CLI commands, SDK exports)\n- One `apis/<name>.md` per API group\n\n**Priority 5 - Guides:**\n- `guides/setup.md` - Dev environment setup\n- `guides/testing.md` - How to run and write tests\n- Other guides as relevant\n\n### Phase 4: Index and Cross-link\n\n1. Build `_index.md` - organized by category with one-line descriptions and links\n2. Ensure every article has a `## See Also` section linking to related articles\n3. Add backlinks: if A references B, B should reference A\n\n### Phase 5: Lint\n\nRun a health check over the wiki:\n- Broken internal links (references to non-existent `.md` files)\n- Orphan pages (not linked from `_index.md` or any other page)\n- Missing coverage (directories/modules with no corresponding article)\n- Stale references (mentions of files/functions that don't exist in codebase)\n- Inconsistent terminology\n\nFix issues found. Log the lint run in `_log.md`.\n\n## Update Workflow\n\nWhen `.llm-wiki/` already exists:\n\n1. **Read `_schema.md`** to understand project metadata and conventions\n2. **Read `_log.md`** to see last update timestamp\n3. **Detect changes** since last wiki build:\n   - `git log --since=\"<last_update>\" --name-status` if git available\n   - Otherwise, compare directory tree against `architecture/directory-structure.md`\n4. **Triage changes:**\n   - New files/directories -> create new articles or update existing ones\n   - Modified files -> re-read and update affected articles\n   - Deleted files -> remove references, mark articles for cleanup\n   - Renamed/moved files -> update paths in all referencing articles\n5. **Update affected articles** - re-read source, rewrite sections as needed\n6. **Update `_index.md`** if new articles added or old ones removed\n7. **Run lint** (same as Phase 5 above)\n8. **Append to `_log.md`** with timestamp, summary of changes\n\n## Writing Guidelines\n\n- **Be factual**: describe what the code does, not what it should do. Cite file paths and line ranges.\n- **Use code snippets**: short inline examples from actual source, not invented ones.\n- **Link aggressively**: every mention of another module/concept should be a markdown link to its article.\n- **Keep articles focused**: one topic per article, 100-500 lines. Split if longer.\n- **Frontmatter**: every article starts with a YAML frontmatter block:\n  ```yaml\n  ---\n  title: Module Name\n  updated: 2026-04-09\n  sources:\n    - src/module/index.ts\n    - src/module/utils.ts\n  ---\n  ```\n- **ASCII diagrams** over external images - they live in version control and render anywhere.\n- **Language**: match the project's primary language. If the codebase comments are in English, write in English. If Chinese, write in Chinese.\n\n## Agent Coordination\n\nFor large codebases (>500 source files), consider dispatching parallel agents:\n- Agent per top-level module to write module articles concurrently\n- One agent for architecture overview after modules are documented\n- One agent for cross-linking and lint\n\n## Gitignore\n\nAdd `.llm-wiki/` to `.gitignore` only if the user prefers it. By default, the wiki is intended to be committed alongside the code so the team benefits.\n\n## Key Principles (from Karpathy)\n\n1. **The wiki is the LLM's domain** - humans rarely edit it directly\n2. **Knowledge compounds** - each query and exploration enriches the wiki\n3. **Index files are critical** - `_index.md` enables the LLM to navigate efficiently\n4. **Lint regularly** - catch rot before it spreads\n5. **Log everything** - `_log.md` provides temporal context for future updates","author":"@staruhub","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/staruhub/ClaudeSkills/tree/main/llm-wiki","license":"MIT","category":"document","lang":"en","tokens":1446,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/article-templates.md","size":3784,"sha256":"c7081d69f040abe439304c19e4f837702aa0f37836399fe61c18111bf41917f1"},{"path":"references/wiki-schema.md","size":4287,"sha256":"1a019c98ba25fa3de2dc35171d76b9356530f1be8e17188cfd5711108227860d"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":[]}}