agentleFS
dafaalzdafaalz/agent-skills/skills/upsert-codebase-docs/SKILL.md

upsert-codebase-docs

Skill2 starsChanged 2 months agoMITView on GitHub

Use when creating or updating AGENTS.md and CODEBASE.md documentation files for a project, auditing documentation drift against git changes, or bootstrapping agent instructions for new repositories. Don't use for writing user guides, product changelogs, or external API documentation.

  • Reads credentials

The file

Show its rules and text

We split this skill into the rules it gives an agent

22 rules. About 0 are common, 17 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈17

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create and maintain high signal documentation files for AI coding agents and developers.

    line 8
  2. Distinctive:

    Follow these six steps in sequence.

    line 20
  3. Distinctive:

    Test runners, linters, and build tooling.

    line 37
  4. Distinctive:

    If Mode B is selected, check for drift indicators:

    line 49
  5. Distinctive:

    If conflicting manifests exist, such as both npm and bun lockfiles, formulate a clarifying question with concrete options and a clear …

    line 56
  6. Distinctive:

    Wait for user validation or adjustments before proceeding to file drafting.

    line 71
  7. Distinctive:

    Never write or overwrite documentation files before securing user approval.

    line 72
  8. Distinctive:

    Update only commands or conventions that changed based on manifest or script updates.

    line 90
  9. Very specific:

    If an existing file exceeds 150 lines, extract secondary domain notes into .agents/references/ rather than deleting developer guidance.

    line 91
  10. Distinctive:

    Ensure the total file length remains at or below 150 lines.

    line 92
  11. Distinctive:

    Write or update core sections:

    line 100
  12. Distinctive:

    Update the verification timestamp to the current date.

    line 110
  13. Very specific:

    Ensure directory .agents/references/ exists by running mkdir -p .agents/references.

    line 112
  14. Very specific:

    If a single domain requires more than 30 lines of technical description, move it into .agents/references/<domain>.md and leave a context …

    line 113
  15. Distinctive:

    Run deterministic line count validation:

    line 121
  16. Distinctive:

    Run the formatting and style audit:

    line 126
  17. Distinctive:

    Verify zero occurrences of em dashes, en dashes, or hyphens acting as dashes.

    line 127
  18. Distinctive:

    Verify colons appear only before explicit lists, tables, or code blocks.

    line 128
  19. Distinctive:

    Verify sentence case headings without decorative emojis.

    line 129
  20. Very specific:

    Search for and eliminate banned AI vocabulary using substitution tables in references/agents-standard.md.

    line 130
  21. Distinctive:

    Run link and path verification:

    line 131
  22. Distinctive:

    Verify every file path and command mentioned exists and functions on disk.

    line 132

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Upsert codebase docs

Create and maintain high signal documentation files for AI coding agents and developers. This skill governs the generation and incremental synchronization of AGENTS.md and CODEBASE.md.

Principles and constraints

  1. Budget limits. AGENTS.md must not exceed 150 lines. CODEBASE.md must not exceed 250 lines.
  2. Progressive disclosure. Move subsystem specifications exceeding 30 lines to .agents/references/ rather than cluttering root files.
  3. Unslop and punctuation rules. Zero em dashes, zero en dashes, and zero hyphens acting as dashes. Restrict colons to introducing lists, tables, or code blocks. Never use mid-sentence colons or pseudo-labels.
  4. Positive operational framing. Pair every negative constraint immediately with a concrete positive action.
  5. Single source of truth. Rely on environment files and live terminal commands rather than copying static code into documentation.

Workflow

Follow these six steps in sequence.

Step 1. Workspace topology and stack profiling

Inspect the target repository to determine structure and technology stack before creating or editing files.

  1. Execute the topology detection script to profile manifests:
    bash scripts/scan-topology.sh .
  2. Classify repository topology using references/topology-detection.md:
    • Single-root application. One primary manifest at root (composer.json, package.json, or Cargo.toml). Generates root AGENTS.md and CODEBASE.md.
    • Multi-tier decoupled architecture. Distinct manifests inside subdirectories like backend/ and frontend/. Generates root orchestrator AGENTS.md alongside dedicated AGENTS.md and CODEBASE.md pairs inside each active subsystem.
    • Monorepo workspace. Monorepo tools managing multiple packages under packages/ or apps/.
  3. Inspect stack manifests and environment files using references/stack-profilers.md to identify:
    • Language and runtime version.
    • Core framework and active database driver (prioritizing .env over .env.example, verified via runtime CLI commands where available).
    • Test runners, linters, and build tooling.
    • Primary packages and third-party integrations.

Completion criterion. A verified inventory of repository topology, active runtime versions, and manifests recorded on disk with zero unverified assumptions.

Step 2. Operational mode selection and ambiguity resolution

Determine whether to run greenfield generation or incremental drift synchronization, and resolve manifest anomalies.

  1. Inspect target directories for existing documentation files:
    • Mode A (Greenfield bootstrap). Target files do not exist. Extract the full project profile and generate initial files using standard templates.
    • Mode B (Incremental drift sync). Target files exist. Audit current code against documentation using references/drift-heuristics.md to update stale sections without overwriting manual developer rules.
  2. If Mode B is selected, check for drift indicators:
    • Migration files added after the last verified date in CODEBASE.md.
    • New routes, controllers, or services introduced in git diff.
    • Dependency additions in package manifests.
    • Database engine or connection mismatches between active .env or runtime CLI and the documented stack.
    • Staleness rule expiry exceeding 4 weeks since the recorded verification date.
  3. Resolve profile ambiguities:
    • If conflicting manifests exist, such as both npm and bun lockfiles, formulate a clarifying question with concrete options and a clear recommended choice.
    • Confirm active branch conventions and staging rules before drafting instructions.

Completion criterion. Target mode confirmed and logged with exact file paths targeted for creation or patching.

Step 3. User alignment gate

Present the discovery summary to the user and secure confirmation before modifying or generating files on disk.

  1. Present the structured discovery brief:
    • Identified repository topology and targeted documentation files.
    • Detected runtime, framework, database, and test commands.
    • Proposed operational mode (Mode A greenfield bootstrap or Mode B incremental drift sync).
    • Core non-default conventions to encode in AGENTS.md.
  2. Secure explicit confirmation:
    • Wait for user validation or adjustments before proceeding to file drafting.
    • Never write or overwrite documentation files before securing user approval.

Completion criterion. Explicit user approval recorded for the proposed documentation plan.

Step 4. Drafting AGENTS.md

Assemble operational instructions in AGENTS.md strictly within the 150-line limit. Consult references/agents-standard.md for exact section anatomy.

  1. In Mode A, write the document with these mandatory sections:
    • Heading stating repository identity and role.
    • Project Context covering runtime, framework, database, and timezone.
    • Documentation Map pointing to CODEBASE.md and any deep files in .agents/references/.
    • Commands Cheatsheet with verified shell commands for dependencies, dev server, tests, and linting.
    • Critical Rules stating absolute boundaries. Pair every prohibition with an explicit allowed action. Include environment security, dependency directory locks, and migration preservation.
    • Non-Default Conventions listing framework gotchas and patterns AI models typically violate.
    • Git Workflow and Definition of Done requiring terminal test verification before completion.
  2. In Mode B, preserve existing custom guidelines:
    • Retain all manual developer instructions and custom rules.
    • Update only commands or conventions that changed based on manifest or script updates.
    • If an existing file exceeds 150 lines, extract secondary domain notes into .agents/references/ rather than deleting developer guidance.
    • Ensure the total file length remains at or below 150 lines.

Completion criterion. AGENTS.md written to disk with verified commands, zero dangling negative rules, and total line count not exceeding 150 lines.

Step 5. Drafting CODEBASE.md

Assemble technical architectural reference in CODEBASE.md strictly within the 250-line limit. Consult references/codebase-standard.md for notation rules.

  1. Write or update core sections:
    • Verification metadata and staleness rule with current ISO date (Last verified: YYYY-MM-DD).
    • Technology Stack table listing layer, technology, and operational boundaries.
    • Architecture Data Flow diagram using clean ASCII text showing request-to-response paths.
    • Annotated Directory Layout highlighting key feature directories and functional ownership.
    • Compact Schema Notation for database entities (one line per table showing primary keys, foreign keys, and critical columns).
    • Compact Routing Matrix mapping essential HTTP verbs, endpoints, handlers, and guards.
  2. In Mode B, execute delimited synchronization:
    • Locate auto-generated blocks bounded by <!-- BEGIN AUTO GENERATED: <SECTION> --> and <!-- END AUTO GENERATED: <SECTION> -->.
    • Refresh content inside the delimiters with latest code state while leaving surrounding narrative untouched.
    • Update the verification timestamp to the current date.
  3. Manage subsystem sprawl:
    • Ensure directory .agents/references/ exists by running mkdir -p .agents/references.
    • If a single domain requires more than 30 lines of technical description, move it into .agents/references/<domain>.md and leave a context pointer in CODEBASE.md.

Completion criterion. CODEBASE.md written to disk with updated staleness date, compact notation, delimited blocks, and total line count not exceeding 250 lines.

Step 6. Verification and unslop audit

Audit generated files against technical standards before concluding the task.

  1. Run deterministic line count validation:
    wc -l AGENTS.md CODEBASE.md
    Confirm AGENTS.md is 150 or fewer lines, and CODEBASE.md is 250 or fewer lines.
  2. Run the formatting and style audit:
    • Verify zero occurrences of em dashes, en dashes, or hyphens acting as dashes.
    • Verify colons appear only before explicit lists, tables, or code blocks.
    • Verify sentence case headings without decorative emojis.
    • Search for and eliminate banned AI vocabulary using substitution tables in references/agents-standard.md.
  3. Run link and path verification:
    • Verify every file path and command mentioned exists and functions on disk.

Completion criterion. Both files satisfy all audit criteria with zero violations recorded.

Quick audit checklist

CheckPassing condition
User alignment gateFindings and target files presented to user and approved before editing files
Line budgetAGENTS.md <= 150 lines, CODEBASE.md <= 250 lines verified with wc -l
Progressive disclosureSubsystems exceeding 30 lines placed in .agents/references/
DelimitersAuto-generated sections in CODEBASE.md wrapped in HTML comment bounds
Style and punctuationZero em dashes, zero mid-sentence colons, sentence case headings
Concrete rulesEvery negative constraint paired with an immediate positive action
Truth groundingAll paths, commands, and schemas match repository reality

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.