README Generator¶
Generate high-quality README documents from codebase evidence, with clear structure, runnable commands, and maintenance rules.
Core Rules¶
- Base every statement on repository evidence (files, code, scripts, workflows, configs).
- If key information is missing, write
Not found in repoinstead of guessing. - Exclude local/private tooling folders by default (for example
.codex/) unless explicitly requested. - Keep naming/paths accurate and consistent with real repository layout.
- Prefer concise sections, bullet lists, and short command blocks.
- Keep internal workflow reporting out of README body by default. Evidence maps, scorecards, and verification-state reporting belong in the assistant response unless the user explicitly asks for them in the document.
- Treat top-level
README.mdas a user-facing homepage first and a maintainer reference second, unless the user explicitly wants an internal-only README.
Pre-Generation Gates (Mandatory)¶
1) Audience and Language Gate¶
Before drafting, determine:
- target readers: contributors, operators, API consumers, or end users
- output language: Chinese / English / bilingual
If unspecified, default to:
- primary language follows existing repo docs
- keep audience assumptions in working notes; only state them in README when they materially help readers
2) Project Type Routing¶
Classify repository and choose template path:
- Service/backend app
- Library/SDK
- CLI tool
- Monorepo (multiple apps/packages)
If uncertain, state assumption explicitly in README.
3) Evidence Completeness Gate¶
Before drafting, verify minimum evidence has been collected:
- At least one entry point identified (
main.go,cmd/,package.json, executable script) - Project type determined (service/library/CLI/monorepo/lightweight)
- Command source located (Makefile, package.json, go.mod, or none)
If the discovery script is available, run it first:
If minimum evidence is insufficient (no entry point found, no build system detected): - Output a degraded README with only Project Overview + "Not found in repo" sections - Mark the output as degraded: true in the assistant response - List exactly what evidence is missing and suggest how to resolve
4) Badge Detection Gate (Mandatory)¶
Badge generation is mandatory for every README generation. Before drafting, scan for badge evidence: - CI workflow files (.github/workflows/*.yml) - Coverage config (codecov, coveralls, Makefile cover target) - Language version (go.mod, package.json engines, pyproject.toml) - License file (LICENSE, LICENSE.md)
If evidence exists, add badges. If no evidence exists for any badge type, skip that badge — do not fabricate. Document badge decisions in the Output Contract (badges_added field).
5) Command Verifiability Gate¶
Do not fabricate command verification or health-check results.
- If commands were executed, you may say so in the assistant response.
- If commands were not executed, do not inject
Verified/Not verified in this environmentlabels into README body by default. - In README itself, prefer evidence-backed install/run commands plus prerequisites.
- Only add explicit verification-state wording inside the README when the user requests it or the repository clearly uses that style for internal docs.
Hard rule: verification-state phrases such as "not executed in this environment", "not verified", "Commands are derived from the Makefile and have not been executed" must never appear inside the README.md file itself. These belong exclusively in the assistant response (Output Contract). Even when the Scorecard checks H2, that check refers to the README file — keep all process language out of it.
Badge Strategy¶
Add badges at the top of README when evidence exists. Detection order:
- CI status: detect from
.github/workflows/*.yml→ - Coverage: detect from coverage config (codecov, coveralls) or Makefile
covertarget - Go version / Language version: detect from
go.mod,package.json engines,pyproject.toml - License: detect from
LICENSEfile → - Release/tag: detect from git tags or release workflow
Badge ordering: CI → Coverage → Language version → License → Release
Rules: - Only add badges with real URLs derivable from repo evidence. - Do not add placeholder badges with fake URLs. - If repo is private and badges won't render, note this and skip.
Private-repo fallback (recommended wording):
Badge note: repository is private; external badge URLs may not render outside authorized viewers.
Community and Governance Files¶
Detect and reference these files when present:
| File | README Action |
|---|---|
LICENSE | Add License section or badge |
CONTRIBUTING.md | Add "Contributing" section linking to it |
CODE_OF_CONDUCT.md | Reference in Contributing section |
SECURITY.md | Add "Security" section linking to it |
CHANGELOG.md | Reference in Release/Versioning section |
If LICENSE is missing, add a note: License: Not found in repo — consider adding a LICENSE file.
Key Evidence Targets¶
Always scan these high-signal files before drafting or refactoring:
- Entrypoints:
main.go,cmd/*, executable scripts,package.json - Build/test hubs:
Makefile,go.mod,pyproject.toml,package.json - CI and release:
.github/workflows/* - Runtime/config:
.env.example,config/*,application.yml,docker-compose.yml - Governance:
LICENSE,CONTRIBUTING.md,SECURITY.md,CHANGELOG.md - Existing docs:
README*.md,docs/*
If any of these are absent, record Not found in repo instead of filling the gap with assumptions.
Command Priority¶
When multiple command sources exist, apply Command Priority in this order:
Makefiletarget when it exists and is clearly maintained- Language-native manifest (
go.mod,package.json,pyproject.toml,Cargo.toml) - CI workflow commands when they confirm the maintained path
- Direct tool invocation only when no stronger source exists
If sources conflict, load references/command-priority.md and resolve the conflict before drafting commands.
Structure Policy¶
Use required + optional sections, not one rigid template.
Required Sections¶
- Badges (when evidence exists)
- Project overview
- Prerequisites (CLI / Service types)
- Quick start
- Code/project structure
- Common commands
- Configuration and environment
- Testing and quality checks
- Documentation maintenance note
For public/open-source homepage-style READMEs, prefer this top order when evidence exists:
- Value proposition
- Highlights / key capabilities
- Prerequisites
- Install
- Quick start
- End-to-end example
- Reference sections (structure, configuration, commands, testing, docs)
Prerequisites section format (CLI / Service types): list required runtime dependencies first, then optional ones. Each entry should state version constraint, purpose, and a setup link when non-trivial. Example:
## Prerequisites
- Go `>= 1.21` ([download](https://go.dev/dl/))
- A GitHub Personal Access Token with `repo` read permission ([create one](https://github.com/settings/tokens))
- _(Optional)_ An OpenAI API key — required only for the AI summary feature
- _(Optional)_ Docker — required only for `make docker-build`
Optional Sections (include only when evidence exists)¶
- Architecture / data flow
- Deployment / operations
- API usage examples
- Release/versioning
- Contributing guide (link to
CONTRIBUTING.mdif present) - License
- Security notes (link to
SECURITY.mdif present) - Contact and support (optional; no forced SLA field)
If a section is not applicable, omit it or mark N/A (reason).
Lightweight Template Mode¶
Use lightweight mode when repository scope is small and a full template would create noise.
Trigger conditions (any 2):
- fewer than 5 top-level functional directories
- no deployment/ops workflows in repo
- no public API/SDK surface
- README target is internal contributors only
Lightweight required sections:
- Project overview
- Quick start
- Common commands
- Project structure (short)
- Testing and quality checks
- Documentation maintenance note
In lightweight mode, skip optional heavy sections unless explicitly requested.
Chinese / Bilingual README Guidelines¶
Apply this section when the repository or user request indicates Chinese or bilingual output.
- Keep English for package names, command names, file paths, environment variables, and precise technical identifiers.
- Translate headings and explanatory prose to match the target audience language.
- Do not use double-language headings like
## Quick Start / 快速开始. - In bilingual mode, use Chinese as the primary prose and keep English technical terms inline.
- Prefer exact Chinese headings such as
## 快速开始,## 项目结构, and## 常用命令.
Example heading style:
README Navigation Rule¶
For long READMEs, navigation is part of usability.
- If the README has many major sections or reads like a long-form reference doc, keep a compact table of contents with major sections only.
- Do not remove an existing useful table of contents solely to reduce length.
- If the README is short enough to scan without scrolling effort, a table of contents can be omitted.
ToC size calibration: ToC length should match project complexity. A simple CLI or single-purpose library should have 7–10 ToC entries at most. Inflating the ToC by listing every section creates noise and obscures the user's actual navigation path.
Exclude from ToC by default (keep in document body for those who scroll):
- Architecture / data flow internals (downgrade to
###subsection under Project Structure) - Contributor-only sections (Testing/CI details, Common Commands reference tables, Docker build steps)
- Any section that is not a direct action step for the primary audience
ToC label / heading consistency rule: the display text of every ToC entry must exactly match the ## heading it links to. If you shorten a ToC label for readability, you must rename the section heading to match. Mismatches disorient readers who click a link and land on a differently-titled section.
Monorepo Rules¶
When the detected project type is monorepo:
- Use a repository overview table instead of a deep tree dump.
- Link to submodule READMEs instead of duplicating every module's internal details.
- Document shared root commands only; module-specific commands belong in each module README.
- If
LICENSEis missing, sayNot found in repoat the root rather than guessing package-level license inheritance.
Load references/monorepo-rules.md before drafting or calibrating a monorepo README.
End-to-End Example Rule¶
For CLI tools, converters, generators, and similar products, prefer at least one end-to-end example that shows:
- the user input command or API call
- the resulting file name, status line, or response shape
- a short excerpt of the generated output when evidence exists
This is usually more useful than showing an isolated output snippet alone.
No-fabrication constraint: if actual output cannot be derived from repository evidence (no sample output files, no test fixtures, no documented response format), show only the invocation and describe the destination generically — do not invent output content.
schema-gen generate --format json --output ./schemas ./internal/models
# → writes schema file(s) to ./schemas/
Never write a fabricated JSON/YAML body as if it were real output when no evidence exists for the exact shape.
Anti-Examples (BAD / GOOD Markdown Pairs)¶
Use these patterns to suppress the most common README failures.
BAD:
## Testing — Status: Not verified in this environment
| Command | Verified |
|---------|----------|
| `make test` | ⚠️ Not verified |
| `make lint` | ✅ Verified |
GOOD:
Topic: process labels.
BAD:
## Maintainer workflow
Install pre-commit hooks, set up internal dashboards, then scroll down for what the project does.
GOOD:
## Overview
Explain the product value first. Move maintainer workflow to a later section or contributor guide.
Topic: Maintainer workflow before value proposition.
BAD:


GOOD:


Topic: badge fabrication.
BAD:
GOOD:
Topic: configuration guessing.
BAD:
GOOD:
## Repository Overview
| Module | Path | Description |
|--------|------|-------------|
| API | `apps/api/` | Public HTTP service |
| Worker | `apps/worker/` | Background jobs |
Topic: monorepo tree dump.
BAD:
GOOD:
Topic: Double-language headings.
BAD:
GOOD:
Topic: Output snippet without input command.
This applies to all process-state language — not just verification tables. Additional low-frequency anti-patterns live in references/anti-examples.md.
Generation Workflow¶
- Detect audience — decide whether the README is for end users, contributors, operators, or mixed readers.
- Detect language — choose English, Chinese, or bilingual output before drafting.
- Discover repository facts — run
scripts/discover_readme_needs.shif available. - Collect key evidence targets — read
main.go,Makefile,go.mod,.github/workflows, config files, and existing README/docs. - Route project type — choose Template A/B/C/D/E based on repo structure.
- Choose command source — apply Command Priority and resolve command conflicts before copying commands.
- Select supporting references — load template, checklist, golden example, bilingual guidance, or monorepo rules only when needed.
- Draft sections — build the README from evidence, keeping homepage-first reader flow.
- Calibrate structure — add or trim ToC, badges, end-to-end examples, and optional sections based on project complexity.
- Polish language — remove internal process wording, duplicated headings, guessed configuration, and filler prose.
- Verify evidence mapping — ensure each non-trivial section maps back to repo files.
- Return output contract — include the evidence mapping, scorecard, degraded flag, and omitted sections in the assistant response.
Output Style¶
- Short, direct prose. Fenced blocks for trees and commands.
- No internal rubric language (
scorecard,pass/fail,verified) in README body unless requested.
Evidence Mapping Output (Required)¶
After generating or refactoring README, output an evidence mapping table in the assistant response, not inside the README itself, unless the user explicitly asks for an in-document appendix:
| README Section | Evidence File(s) | Evidence Snippet/Reason |
|---|---|---|
| Quick Start | Makefile, go.mod | target/command exists |
| Configuration | .env.example, config/* | variables defined |
| Testing | Makefile, CI workflow | test/lint commands present |
Rules:
- Every non-trivial section should map to at least one evidence source.
- If evidence is missing, map the section to
Not found in repo. - Keep mapping concise (one line per section is enough).
README Update Triggers¶
When these changes occur, the corresponding README sections should be updated:
| Repository Change | README Sections to Update |
|---|---|
New cmd/*/main.go entrypoint added | Project Structure, Common Commands, Quick Start |
| Environment variable added/changed | Configuration and Environment |
| Makefile target added/renamed | Common Commands |
| CI workflow changed | Badges, Testing and Quality |
| New package/module added | Project Structure |
| API endpoint added/changed | API Usage Examples (if present) |
| Deployment config changed | Deployment / Operations (if present) |
| Dependency major version bumped | Quick Start prerequisites |
LICENSE / CONTRIBUTING.md added | License, Contributing sections |
| Go version / Node version bumped | Badges, Quick Start prerequisites |
Use this matrix to check README staleness after code changes. When updating docs with update-doc skill, cross-reference this table.
Output Contract (Mandatory Fields)¶
Every README generation or refactoring must produce these outputs in the assistant response:
| # | Field | Required | Description |
|---|---|---|---|
| 1 | project_type | Always | service / library / cli / monorepo / lightweight |
| 2 | language | Always | en / zh / bilingual |
| 3 | template_used | Always | Template A–E name |
| 4 | evidence_mapping | Always | Section → evidence file table |
| 5 | scorecard | Always | 3-tier scorecard result |
| 6 | degraded | When applicable | true/false — whether evidence was insufficient |
| 7 | missing_evidence | When degraded | List of missing items and suggested actions |
| 8 | badges_added | When applicable | List of badge types added, or "skipped (reason)" |
| 9 | sections_omitted | When applicable | Sections skipped with reason |
Machine-Readable Summary (JSON)¶
When the user requests structured output or for CI integration, append:
{
"project_type": "service",
"language": "zh",
"template_used": "Template A: Service",
"degraded": false,
"scorecard": {
"critical": "4/4",
"standard": "5/6",
"hygiene": "4/4",
"result": "PASS"
},
"badges_added": ["CI", "Coverage", "Go Version", "License"],
"sections_omitted": [],
"missing_evidence": []
}
README Quality Scorecard (3-Tier)¶
Critical Tier (any FAIL → overall FAIL)¶
| # | Check | PASS Rule |
|---|---|---|
| C1 | Evidence-backed claims | Every non-trivial statement traces to a repo file |
| C2 | No fabricated content | Zero guessed commands, URLs, config values, or paths |
| C3 | Quick Start present and actionable | Reader can run the project in ≤ 3 steps |
| C4 | Correct project type routing | Template matches actual repo layout |
Standard Tier (≥ 4/6 to PASS)¶
| # | Check | PASS Rule |
|---|---|---|
| S1 | Command source attribution | Commands traced to Makefile / scripts / native tools |
| S2 | Structure section with purpose | Key directories listed with one-line description |
| S3 | Config/env section present | Required variables documented, source file cited |
| S4 | Testing commands included | At least test + lint commands with practical defaults |
| S5 | Badges evidence-based | Only real URLs; private-repo fallback applied if needed |
| S6 | Audience and language explicit | Stated in working notes or README when it helps readers |
Hygiene Tier (≥ 3/4 to PASS)¶
| # | Check | PASS Rule |
|---|---|---|
| H1 | Maintenance trigger note | "Update this README when..." section present |
| H2 | No internal process labels | No Verified / PASS/FAIL / scorecard language in README body. Also excludes execution-state phrases like "not executed in this environment" — those belong in the Output Contract only. |
| H3 | Navigation and ToC quality | TOC present when needed; size calibrated to project complexity (7–10 entries for simple projects); contributor-only sections excluded; every ToC label matches its ## heading exactly |
| H4 | Optional sections gated | Architecture / Deployment / API only when evidence exists |
Output format: Critical: X/4 | Standard: X/6 | Hygiene: X/4 → PASS/FAIL
Skill Maintenance¶
Run regression checks for this skill with:
Load References Selectively¶
scripts/discover_readme_needs.shRun first (step 1 of Generation Workflow) to collect repo facts deterministically.references/templates.mdLoad when generating a new README from scratch or switching project type template.references/golden-<type>.md(service / library / cli / monorepo / lightweight) Load only the file matching the detected project type when calibrating output quality. Seereferences/golden-examples.mdfor the index.references/command-priority.mdLoad only when command conflicts appear (e.g., Makefile + package.json + CI scripts all define overlapping commands).references/checklist.mdLoad only in refactor mode (updating an existing README) during final review phase.references/anti-examples.mdLoad only when refactoring an existing README that may contain low-frequency anti-patterns (tree dumps, double-language headings, missing input commands).references/bilingual-guidelines.mdLoad only when the output language is Chinese or bilingual for heading style, language-split rules, and bilingual anti-patterns.references/monorepo-rules.mdLoad only when the detected project type is monorepo for tree-depth limits, per-app pointer tables, and submodule README linking rules.