|
| 1 | +--- |
| 2 | +name: zread |
| 3 | +description: Produce and consume a wiki-style knowledge base for a code repository via the `zread` CLI and its on-disk output under `./.zread/wiki/`. Use this skill whenever the user wants to understand, onboard onto, explore, summarize, map, or get an overview of an unfamiliar codebase; asks for architecture docs, a project wiki, a repo walkthrough, module/package explanations, or "what does this repo do"; wants to generate, regenerate, resume, browse, or serve code documentation locally; or mentions zread / zread.ai directly. Also use it proactively before diving into a large unknown repo — if `./.zread/wiki/current` exists, read the generated pages instead of crawling source file-by-file; if it doesn't, consider offering to run `zread generate`. The trigger is the intent (understand a codebase through generated docs), not the literal word "zread". |
| 4 | +--- |
| 5 | + |
| 6 | +# zread skill |
| 7 | + |
| 8 | +`zread` is a CLI that generates wiki documentation from code in the current |
| 9 | +workspace using an LLM. Output lives under `./.zread/wiki/` in the workspace; |
| 10 | +public repos can also be viewed at https://zread.ai. |
| 11 | + |
| 12 | +This skill is intended for agent use. Read generated files directly from disk, |
| 13 | +and use `--stdio` as the default mode for any zread command instead of trying |
| 14 | +to parse the human TUI. |
| 15 | + |
| 16 | +## On-disk layout (read these directly) |
| 17 | + |
| 18 | +Always run `zread` from the workspace root. After a successful generation: |
| 19 | + |
| 20 | +- `./.zread/wiki/current` — text file containing the active version id |
| 21 | + (e.g. `2026-03-12-010203`). |
| 22 | +- `./.zread/wiki/versions/<id>/wiki.json` — TOC: `{id, generated_at, language, |
| 23 | + pages: [{slug, title, file, section, group, level}]}`. |
| 24 | +- `./.zread/wiki/versions/<id>/<file>` — page markdown referenced by `pages[*].file`. |
| 25 | +- `./.zread/wiki/drafts/` — in-progress generation; presence means a previous |
| 26 | + run did not finish. `drafts/wiki.json` exists once the catalog phase |
| 27 | + completed. |
| 28 | +- `~/.zread/config.yaml` — global config (LLM provider, language, concurrency). |
| 29 | +- `~/.zread/login.json` — presence indicates the user has logged in. |
| 30 | + |
| 31 | +To answer questions about a codebase that already has zread output, read these |
| 32 | +files directly with the file tools — do not invoke `zread browse`. |
| 33 | + |
| 34 | +## Commands |
| 35 | + |
| 36 | +| Command | Purpose | Key flags | |
| 37 | +|---|---|---| |
| 38 | +| `zread generate` | Generate wiki for cwd | `-y/--yes`, `--draft resume\|clear\|cancel`, `--skip-failed`, `--stdio` | |
| 39 | +| `zread browse` | Serve docs at http://localhost:9681+ and open browser | `--generate`, `--version <id>`, `--host`, `--port`, `--stdio` | |
| 40 | +| `zread login` | OAuth into BigModel/Z.AI to obtain an API key | `--custom`, `--model`, `--stdio` | |
| 41 | +| `zread config` | Edit `~/.zread/config.yaml` | `--stdio` | |
| 42 | +| `zread update` | Self-update CLI | `--stdio` | |
| 43 | +| `zread version` | Print version | `--stdio` | |
| 44 | + |
| 45 | +`--stdio` is supported on every command and turns the process into a JSON-line |
| 46 | +machine protocol on stdin/stdout. See |
| 47 | +[references/stdio-protocol.md](./references/stdio-protocol.md) for the wire |
| 48 | +format (events, `waiting_for`, `done`, `quit`). Load it whenever zread is |
| 49 | +invoked from another program/agent. |
| 50 | + |
| 51 | +## Decision tree for an AI agent |
| 52 | + |
| 53 | +1. **User wants to read existing wiki content?** |
| 54 | + - Check `./.zread/wiki/current`. If present, read `wiki.json` and the page |
| 55 | + markdown directly. No CLI invocation needed. |
| 56 | + - For known *public* GitHub repos, prefer the `mcp__zread__*` tools |
| 57 | + (`get_repo_structure`, `read_file`, `search_doc`) over running the CLI. |
| 58 | + |
| 59 | +2. **User wants to (re)generate docs?** |
| 60 | + - Confirm with the user first — `generate` is long-running, calls an LLM, |
| 61 | + and writes files. Get explicit consent in unfamiliar directories. |
| 62 | + - Verify `~/.zread/login.json` exists or `~/.zread/config.yaml` has an |
| 63 | + `llm.api_key`. If neither, run `zread login` first. |
| 64 | + - If `./.zread/wiki/drafts/` exists, decide: |
| 65 | + - resume previous run → `zread generate --draft resume -y` |
| 66 | + - throw away and start fresh → `zread generate --draft clear -y` |
| 67 | + - Otherwise: `zread generate -y`. |
| 68 | + - To not block on a few failing pages: add `--skip-failed`. |
| 69 | + |
| 70 | +3. **User wants to view docs in a browser?** |
| 71 | + - `zread browse` (add `--generate` to bootstrap if no wiki exists yet). |
| 72 | + |
| 73 | +4. **User wants to script zread / consume output programmatically?** |
| 74 | + - Use `--stdio` and follow stdio-protocol.md. Do not screen-scrape the TUI. |
| 75 | + |
| 76 | +## Non-interactive invocation rules |
| 77 | + |
| 78 | +- Always pass `-y` to `generate` when running unattended; otherwise it stops |
| 79 | + at a catalog confirmation gate. |
| 80 | +- Always set `--draft` explicitly when a draft may exist, so the command does |
| 81 | + not prompt. |
| 82 | +- For any command run from another agent/script, use `--stdio` so output is |
| 83 | + parseable JSON instead of ANSI TUI frames. |
| 84 | +- `zread` writes logs to `~/.zread/log/zread.log` — read this if a run fails |
| 85 | + silently. |
| 86 | + |
| 87 | +## Safety / blast radius |
| 88 | + |
| 89 | +- `generate` consumes LLM tokens (real cost) and can run for many minutes on |
| 90 | + large repos. Confirm before launching. |
| 91 | +- `generate` writes only under `./.zread/` and does not commit anything to |
| 92 | + git. It is safe to delete `./.zread/wiki/drafts/` to recover from a stuck |
| 93 | + state. |
| 94 | +- `update` replaces the zread binary in place and is hard to reverse — only |
| 95 | + run it when the user explicitly asks. |
| 96 | +- `login` opens a browser for OAuth; do not run it in a non-interactive |
| 97 | + context unless the user has asked for it. |
| 98 | + |
| 99 | +## Reference files |
| 100 | + |
| 101 | +- [references/stdio-protocol.md](./references/stdio-protocol.md) — JSON-line |
| 102 | + wire protocol shared by every command's `--stdio` mode. Load when |
| 103 | + programmatically driving zread. |
0 commit comments