docs-from-code — Build docs from a code repository
The actual work is done by the docs-code-crawler subagent (Haiku, pinned model) shipped in docs-claude-plugins. This skill is the knowledge base — the subagent is the executor.
Workflow#
- Resolve the repo. Accept
github.com/<owner>/<repo>or a local path. For GitHub URLs, usegh repo clone --depth 1into a temp directory; for local paths, work in place.- Take the project name from the repo name (the
<repo>part afterowner/), not from a guess. Use it for thedocs-output/<name>/folder and the workspace display name. If you're working from an unnamed local path with no clear name, ask the user rather than inventing one.
- Take the project name from the repo name (the
- Detect the project type. Inspect root files:
package.json(Node/TS),pyproject.toml/setup.py(Python),go.mod(Go),Cargo.toml(Rust),*.csproj(.NET). Pick the strongest signal; on conflict, prefer the one with alib/src/pkgdirectory. - Extract the README spine. Convert the root
README.mdintodocs-output/<name>/README.md. Split long top-level sections (## Installation,## Usage,## API) into dedicated pages undergetting-started/,guides/,api/. - Enumerate the public API surface. For Node/TS: read
package.json#exportsand the entry files; for Python: read__all__from the top package; for Go: list exported identifiers from each top-level package. Generate one Markdown file per module / package underapi/. - Pull in examples. If
examples/,samples/, ordemo/exists, copy each subfolder's README (or generate one from the file tree) intoguides/<example>.md. - Read configuration docs. Look for
.env.example,config/*.example.*,docker-compose.yml— generate aguides/configuration.mdlisting variables with descriptions pulled from adjacent comments. - Write
_branding.json. Source:package.json#author, GitHub repo description, repo avatar fromhttps://github.com/<owner>.png. No accent color is detected here — leaveaccentColorabsent so the workspace configurator skipsupdate_brandingrather than picking a default.
Guardrails#
- Never commit secrets — skip
.env,*.key,*.pem, anything matching common token patterns (sk-,ghp_,AKIA). - Cap output at ~50 pages. If the repo has 200 source files, group by package, not by file.
- Active voice, second person, sentence-case headings, no filler words. Tag every code block with the language inferred from the file extension.
- Do not invent API documentation. If a function has no docstring / comment, list its signature only and add
TODO: describe what this does. - The project name comes from the repo name, never invented — ask the user when it can't be determined.
- When committing into an existing repo, write pages to the repo root (
README.md,getting-started/…,guides/…,api/…), or into an existingdocs/folder if the repo already has one. Never wrap a fresh repo's pages in a new top-leveldocs/directory. - Use relative links between pages (
./guides/configuration.md, nothttps://...).
Acceptance Criteria#
- Project type identified from root config files
- README split into structured pages without losing content
- Public API surface enumerated with one page per module / package
- Examples and configuration captured as separate pages when sources exist
-
_branding.jsonwritten without a fabricated accent color - No secrets present in the output folder