code-library-docs
Overview
Cache-first, docs-first library understanding. Prefer repo-native llms.txt, skills/, and docs/ before inventing summaries. If repo has no usable docs, build them once, cache them, reuse them.
When to Use
- New dependency feels opaque
- Need fast mental model of repo/library
- Existing local store may already have summary
- Need
AGENTS.mdthat routes to best docs - Need fallback
llms.txtfor docs-poor repos
Flow
need library understanding?
-> check local cache
-> hit: read AGENTS.md + linked docs
-> miss: gh clone repo into cache
-> inspect repo llms.txt / skills/ / docs/
-> found: link them from cache AGENTS.md
-> none: generate cache llms.txt + brief
Cache Layout
$XDG_CACHE_HOME/agent-library-docs/
└── <owner>__<repo>/
├── repo/
├── AGENTS.md
├── llms.txt
├── briefs/
└── meta.json
Quick Reference
| Item | Rule |
|---|---|
| Cache key | owner__repo |
| Clone target | .../<repo-key>/repo |
| Discovery order | llms.txt -> skills/ -> docs/ |
| Generated docs | only when repo has none worth linking |
Implementation
- Search cache for repo key.
- If missing,
gh repo cloneinto cache$XDG_CACHE_HOME/agent-library-docs/<owner>__<repo>/repo/. - In cache
AGENTS.md, link repo-nativellms.txt,skills/,docs/in that order. - If none exist, link cache
llms.txtand generate it with a research-oriented subagent. - Store the useful brief beside it; reuse on next lookup.
Example
github.com/acme/widgets -> cache key acme__widgets
Common Mistakes
- Cloning twice instead of reusing cache
- Writing summary before checking repo-native docs
- Hiding native
llms.txtunder generated junk - Using repo name only -> collisions
- Treating generated brief like source truth