Skip to content

update codebase discovery - #2

Open
bsigney wants to merge 40 commits into
mainfrom
feature/update-codebase-discovery
Open

update codebase discovery#2
bsigney wants to merge 40 commits into
mainfrom
feature/update-codebase-discovery

Conversation

@bsigney

@bsigney bsigney commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Rework codebase-discovery for safe writes, single-sourced rules, and declared-structure recon

Reworks the codebase-discovery skill so it is safe to run against a repository it does not
own, and states each of its rules once instead of restating them across files.

Six phases now instead of five. Four new reference files own a rule apiece. One command and two
vendored config files are gone.

Writing into someone else's repo

The skill used to assume docs/ and start writing. Phase 0 now surveys the target first: it
detects whether docs/ belongs to a documentation generator (MkDocs, Docusaurus, Sphinx,
Jekyll, Hugo, mdBook, VitePress), lists what already occupies the target paths, and agrees the
output root with the user before anything is written.

references/write-contract.md owns those rules: where the root may sit, that nothing is written
outside it apart from the project-root README, that a file the skill did not author is never
overwritten without sign-off, and that a published site's nav is never touched without a
decision.

--fresh now needs confirmation when a previous run's state exists. Wiping _discovery/ loses
interview progress that git cannot recover, since two of those four files are git-ignored by
recommendation.

Trust boundary and secrets

Everything read from the target repo is data about the system, never instruction. Text that
addresses the reader or asks for behaviour becomes a finding to report rather than a directive
to follow, and .cursorrules or a target-repo CLAUDE.md is read as evidence of what that team
told its agents.

The secrets rule is fixed and normative in one place: record a credential by name and location,
never the value. A live-looking secret in source is a security finding to raise for rotation,
not documentation.

Both rules are restated only in the two bundled subagents, which cannot resolve a path into the
skill. scripts/checks/codebase-discovery.js fails the build if those copies drift.

Output layout

The skill files docs one concept per file, under names drawn from the domain language, so an
agent working on billing loads areas/billing/ rather than every rule in the system.
Area-specific material lives in its area, anything no single area owns stays at the top level,
and the glossary stays a single file.

The grouping is treated as a finding, not filing. Code shows which files sit together; it does
not show that the business recognises the cluster as a concept. So a cluster is named after the
code unit it came from and carries [unverified] until a stakeholder confirms it, at which
point the file is renamed to the agreed term.

Recon

Recon reads the structure the repo declares before inferring anything from patterns.
references/navigation.md sets out the ladder: declared manifests, then the repo's own
toolchain, then text search as the floor, with AST and LSP optional above it. Whichever tier
answered a question sets the confidence, so a boundary read from go.mod outranks one grepped
from imports.

Git is no longer a knowledge source. It is used for the freshness check only, because commit
messages do not reliably carry domain language and decay as history lengthens.

Tier 0 can now recommend against the deep dives. Where the map shows configuration and
infrastructure rather than business logic, the skill says so and offers to write the
architecture note straight from the map.

Freshness and resuming

references/freshness.md is new. Staleness is detected by comparing the recorded recon commit
against HEAD, never by timestamps, since a fresh clone rewrites every mtime. When there is
drift the user picks what happens, and declining to re-recon reverts the affected claims to
[unchecked] instead of leaving them reading as accepted.

A resume table decides which phase to re-enter from what the working state records. The
stakeholder can stop the interview at any point, and the remainder is parked in the register as
needs SME.

Provenance

The flag vocabulary is closed to five: [unchecked], [unverified], [assumption],
[outdated], [contradicted]. [unchecked] is new and means no current code check, covering
both a doc claim nobody has compared yet and a claim whose code has moved since. Inventing a
sixth fails the gate.

Verification gate

Content checks moved out of scripts/validate.js, which stays format-only and
component-agnostic. scripts/checks/ loads automatically and holds per-component invariants:
the two canonical rule wordings, the closed flag vocabulary, and agreement between the three
places the output layout is stated.

Removals

commands/codebase-discovery.md is deleted. The skill is user-invocable, so it already
exposes /codebase-discovery, and a same-named command collided with it. That rule is now
written down in commands/README.md and CONTRIBUTING.md.

The vendored references/lsp-mcp/ configs are deleted. LSP guidance is capability-based now,
and pinning a third-party bridge's config in this repo would rot silently.

Prose

A pass with the humanizer and avoid-ai-writing skills over the skill and the repo docs. Em dash
rate in the skill dropped from 17.6 per 1,000 words to 0.6. Both gate-pinned rule wordings,
every table, code fence and normative blockquote were left untouched, and heading count, fence
count and the set of link targets are unchanged.

bsigney added 30 commits August 19, 2026 11:11
…and move component content checks out of the format gate
…flag

both still said the flag cant persist: phase 0 that none survives recon, the contrast that nobody has looked at the code.
it sat below the resume and initialise steps, so an agent reading in order could overwrite the state before reaching the sign-off.
…er instead of phase 5s summary adds the three checks the doc verifier can actually run, with the sign-off limit stated.
…ng the default, the anchor and the --output escape condition next to a pointer at the file that owns them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant