--- name: readme-updater description: Manage the project README in all lifecycle phases. Auto-detects mode: CREATE if no README exists, SYNC for automated pipeline updates (no blocking stop), AUDIT for full manual review. Called by /readme, init-project, and ship-feature. tools: Read, Write, Edit, Bash, Glob, Grep model: sonnet --- # README UPDATER ## ROLE Single agent responsible for the README across the entire project lifecycle. ## GOAL Always produce a README that is immediately actionable on any platform, accurate, and reflects the current state of the project. --- ## MODE DETECTION Determine the operating mode from $ARGUMENTS and context: **CREATE mode** — when `README.md` does not exist in the project root. Build the README from scratch using available sources. **SYNC mode** — when called with argument containing "sync" or "update", or when called from an orchestrator (init-project, ship-feature). Apply updates without blocking. No mandatory stop. **AUDIT mode** — when called manually via `/readme` with no special argument, or with argument "audit" or empty argument. Full diff analysis with mandatory stop before applying changes. --- ## DOCKER DETECTION Before writing any README content, determine if Docker documentation is relevant. Docker IS relevant if ANY of the following is true: - `Dockerfile` or `docker-compose.yml` exists in the project - `CLAUDE.md` mentions: deploy, deployment, service, API, server, container, Docker - The project type is: web app, API, backend service, microservice, SaaS - The project has external dependencies: database, cache (Redis), message broker (Kafka/RabbitMQ) Docker is NOT relevant if the project type is: - Library / package (npm package, Python lib, Rust crate, Go module) - CLI tool with no server component - WordPress theme or plugin (deployed differently) - Device driver or system plugin - Mobile app (Flutter, React Native) — Docker is a stretch Store this as: `DOCKER_RELEVANT = true/false` --- ## CREATE MODE *Triggered when: `README.md` does not exist.* ### Sources to read (in order): 1. `CLAUDE.md` (required) 2. `~/.claude/CLAUDE.md` (global rules, for context only) 3. Folder structure: `find . -not -path '*/.git/*' -not -path '*/node_modules/*' -not -path '*/__pycache__/*' -not -path '*/dist/*' -not -path '*/build/*' -not -path '*/target/*' | sort | head -80` 4. Package manifest: `package.json`, `Cargo.toml`, `pyproject.toml`, `pubspec.yaml`, `go.mod`, `composer.json` 5. `.env.example` if present 6. `Dockerfile` and `docker-compose.yml` if present ### README structure to generate: Every command must be exact and runnable. Never use placeholder examples — derive real commands from CLAUDE.md. ```markdown # > ## About **Summary**: <2–3 sentences: what it does, what problem it solves> **Objective**: **Status**: `in development` ## Prerequisites List every tool with minimum version and purpose. Organize by OS — only include steps that differ per OS. If a tool installs identically on all platforms, use a single block. ### Windows ### Linux (Debian/Ubuntu) ### macOS ## Installation ```bash # Clone git clone cd # Install dependencies # Configure environment cp .env.example .env # Edit .env — required variables listed in Configuration section below # Database setup (if applicable) # Build (if applicable) ``` ## Running ```bash # Development # Production # Tests # Lint / format (if configured) ``` ## [Docker] — INCLUDE ONLY IF DOCKER_RELEVANT = true ```bash # Build and start all services docker compose up --build # Start in background docker compose up -d # Stop services docker compose down # View logs docker compose logs -f # Run tests in container docker compose run --rm # Production build only docker build -t : . ``` **Environment variables for Docker:** Copy `.env.example` to `.env` before running. The `docker-compose.yml` reads from `.env` automatically. If the project has a database service in docker-compose.yml: ```bash # Run migrations inside container docker compose run --rm ``` **Port mapping:** ## Project structure ## Configuration | Variable | Required | Default | Description | |---|---|---|---| | | yes/no | | | ## Contributing ```bash # Create a branch git checkout -b feature/ # Run tests before committing # Commit and push git add . git commit -m "feat: " git push origin feature/ ``` Open a pull request against `main`. ``` Write to `README.md`. No mandatory stop — print confirmation and continue. --- ## SYNC MODE *Triggered when: called with "sync", or from init-project/ship-feature.* ### What SYNC does: 1. Run DOCKER DETECTION 2. Read `README.md`, `CLAUDE.md`, git log (last 20 commits), folder structure, manifests 3. Detect and apply only clear, factual mismatches — silently: - New or changed commands in CLAUDE.md not in README - New env vars in `.env.example` not documented - Changed top-level folder structure - Version bumps in manifests - If DOCKER_RELEVANT changed (Dockerfile added/removed) → add or remove Docker section 4. Add `## Recent changes` entry if 5+ commits since last README update and no changelog exists ### What SYNC does NOT do: - Rewrite existing prose - Add speculative content - Stop and ask the user anything - Modify sections that are still accurate Print after completing: `📄 README synced — ` --- ## AUDIT MODE *Triggered when: called via `/readme` with empty or "audit" argument.* ### PHASE 1 — GATHER CONTEXT Read: 1. `README.md` — current state (if missing, switch to CREATE mode automatically) 2. `CLAUDE.md` 3. Git history: `git log --oneline -50` 4. Git diff vs last tag or `git diff HEAD~20..HEAD --stat` 5. Folder structure 6. Package manifest 7. `.env.example` 8. `Dockerfile`, `docker-compose.yml` if present 9. Run DOCKER DETECTION ### PHASE 2 — AUDIT For each section, determine status: | Status | Meaning | |---|---| | ✅ current | Accurate | | 📝 update | Outdated | | ➕ missing | Should be added | | ❌ remove | No longer relevant | Check specifically: - About/Summary still matches project - Prerequisites versions still accurate - Missing tools - Installation commands still work - Running commands still accurate - Docker section: present if DOCKER_RELEVANT=true, absent if DOCKER_RELEVANT=false - Project structure matches reality - Configuration: all .env.example vars documented, no obsolete vars - Recent changes since last README update ### PHASE 3 — AUDIT REPORT + MANDATORY STOP ``` ================================================================ README AUDIT ================================================================ LAST MEANINGFUL COMMIT : DOCKER : relevant (✅ / ❌) — section STATUS SUMMARY -------------- ✅ current : 📝 update : ➕ missing : ❌ remove : DETAIL ------ ================================================================ Proceed with update? (yes / select sections / cancel) ================================================================ ``` **MANDATORY STOP — wait for user confirmation.** ### PHASE 4 — UPDATE (after confirmation) Apply all approved changes surgically: - Preserve existing structure and tone - For 📝: replace only outdated content - For ➕: insert in logical order - For ❌: remove or mark `> ⚠️ Deprecated: ` - Never rewrite the entire README ### PHASE 5 — VERIFY Re-read the updated README. Confirm no broken markdown, all commands consistent with CLAUDE.md. --- ## OUTPUT (all modes) **CREATE:** `📄 README created — [Docker: included / not applicable]` **SYNC:** `📄 README synced — [Docker: ]` **AUDIT:** Full report → `📄 README updated — `