From codebase-survey
Incremental refresh of an existing codebase survey. With no argument, each module is diffed from its own recorded surveyed_sha to HEAD. With a commit range or PR# argument, that range is used uniformly. Maps changed paths to affected module docs, dispatches narrowly-scoped subagents for only those modules, then bumps each touched module's surveyed_sha. Model-invocable so it can be wired to a post-merge hook later.
How this skill is triggered — by the user, by Claude, or both
Slash command
/codebase-survey:codebase-survey-update [commit-range | PR#][commit-range | PR#]opusThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
You refresh an existing survey incrementally. Init produces the baseline; the
You refresh an existing survey incrementally. Init produces the baseline; the module skill produces detail; this skill keeps both current as the codebase moves. The goal is a small, scoped pass: only re-survey the modules whose code actually changed, and only re-derive instructions if their sources moved.
$ARGUMENTS is optional:
surveyed_sha
(recorded in its <module>/CODEBASE.md front-matter) to HEAD. Different
modules may have different bases. This is the default and the most common
mode.abc123..HEAD, main..feature/foo, HEAD~5..HEAD) —
use the same range for every module. Useful when reviewing one logical
change.123 or #123) — fetch the PR's changed file list
via gh pr diff --name-only <N>. Maps each changed file to its module(s)
and treats the PR's base..head as the range for those modules.Read top-level CODEBASE.md. Extract the module map. If absent, abort —
/codebase-survey-init must run first.
Build the per-module change set:
surveyed_sha from
<path>/CODEBASE.md front-matter. Run git diff --name-only <surveyed_sha>..HEAD -- <module-path>.
If surveyed_sha is (no git) or absent, treat the module as fully
dirty (re-survey it from scratch).git diff --name-only <range> -- <module-path>.gh pr view <N> --json baseRefOid,headRefOid to get
the base..head SHAs, then proceed as range mode.If git is unavailable or the SHAs are unknown, surface the failure and ask the user how to proceed (full re-run? skip update? specify a range?).
Map changed files to survey targets:
| Path | Affects |
|---|---|
<module-path>/... | that module's CODEBASE.md |
CODEBASE.md (root) | top-level |
docs/codebase/architecture.md, tech-stack.md, operations.md | top-level survey context |
Manifest files (package.json, Cargo.toml, …) at repo root | top-level survey + dep-grapher reruns on every module that depends on root manifest |
| New top-level directory not in any module's path | unmapped — surface to user; may indicate a new module |
Files under .github/workflows/, root Dockerfile*, k8s/, etc. | repo-level operations only (does not invalidate modules) |
Build two sets:
Report the scope to the user before doing work — a one-line per module
("packages/api: 12 changed files, will re-survey") plus any unmapped
paths flagged.
Stop and ask the user before continuing if any of these are true:
<module>/CODEBASE.md (or top-level) has a
survey_schema that doesn't match the current schema (1). Patch logic
doesn't apply across schema versions — the user should re-init or run a
full module re-survey.CODEBASE.md stub). Surface it; don't invent a place for it.For each module in Modules to re-survey, invoke the same orchestration
as /codebase-survey-module would: spawn the five subagents in parallel
(dep-grapher, api-surface-extractor, wire-api-extractor, test-auditor,
ops-detective) targeting the module path, then assemble the new
<module>/CODEBASE.md.
Optimisations specific to update mode:
wire-api-extractor and api-surface-extractor — the language and wire
surface haven't changed. Always rerun test-auditor in this case.*.md outside the survey itself), you
may skip everything and just bump surveyed_sha + surveyed_at. Note
this in the run report so the user can verify.Preserve hand-edits in Architectural Deviations and Open Questions
exactly as /codebase-survey-module does.
If Top-level updates needed is non-empty:
/codebase-survey-module <path> to populate it."ops-detective on the repo root and
rewrite docs/codebase/operations.md's body — but only if its
front-matter has generated_by: codebase-architecture-assessment or
generated_by: codebase-survey-init (stub). If generated_by is absent
or unrecognised, treat the file as human-authored, surface the ops
changes to the user, and stop short of the rewrite.Tech Stack section in CODEBASE.md.Bump the top-level surveyed_sha only when the top-level file's body
actually changed. A module-only refresh leaves the top-level SHA alone —
it tracks repo-wide structural state, not the union of module states.
CLAUDE.md files were derived from these surveys. Any module re-surveyed
in this run has a new surveyed_sha, which means CLAUDE.md's
derived_from_survey_sha is now stale. After the survey writes are done:
CLAUDE.md (and any <module>/CLAUDE.md) front-matter.derived_from_survey_sha references a survey
file you just rewrote, mark it as drifted in the run summary.Do not rewrite CLAUDE.md here — /codebase-derive-instructions is
the only skill that writes it. Surface the drift in your hand-off.
Architectural assessment is not auto-rerun. Diffs almost never invalidate
cross-cutting findings cleanly, and rerunning /codebase-architecture-assessment
on every minor change would thrash assessment.md. Surface a hint
("Several modules changed — consider rerunning /codebase-architecture-assessment")
when more than ~30% of modules were re-surveyed in one run, but stop there.
Report concisely:
CLAUDE.md files now drifted (will need /codebase-derive-instructions).Do not commit. The user reviews and runs /commit.
surveyed_sha after this run
equals git rev-parse HEAD only if the module was actually re-surveyed.
Skipped modules retain their old SHA so the next update can still detect
their changes.CLAUDE.md and never commits, so
it's safe to wire to a post-merge hook later — that hook can simply
surface a list of drifts for human review.surveyed_sha.CLAUDE.md. This skill flags drift; it doesn't
rewrite. Keeping the rewriting in /codebase-derive-instructions keeps
the rule chain auditable.npx claudepluginhub mtrense/skills --plugin codebase-surveyFetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.
Applies a firm's KYC/AML rules grid to parsed onboarding records: assigns risk rating, checks required documents, outputs rule outcomes with citations, and routes for escalation.
Generates daily or weekly digests of activity from connected sources (chat, email, docs, tasks, CRM), highlighting action items, decisions, mentions, and project updates.