Skip to content
Back to skills

Codebase Wiki

ASecurity

Maintain an evidence-backed wiki of a codebase's features, requirements, implementation, and test verification, kept current from Git changes

  • 130 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentsbashgitapidatabasedocumentation

Works with

  • cursor
  • cli
  • api
  • mcp

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add jellydn/my-ai-tools --skill codebase-wiki --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Codebase Wiki?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Codebase Wiki
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jellydn-codebase-wiki/badge)](https://www.skillsdirectory.com/skills/jellydn-codebase-wiki)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: codebase-wiki
description: "Maintain an evidence-backed wiki of a codebase's features, requirements, implementation, and test verification, kept current from Git changes"
license: MIT
compatibility: cline, claude, opencode, amp, codex, gemini, cursor, pi
hint: Use when documenting what a codebase does feature by feature, checking requirements against code and tests, finding features a change affects, or finding stale code documentation
user-invocable: true
metadata:
  audience: all
  workflow: knowledge-management
---

# Codebase Wiki

A living, evidence-backed software knowledge base that continuously tracks business features, implementation, requirements, and verification across an evolving codebase.

This is the codebase companion to `llm-wiki`. Use `llm-wiki` for a wiki built from documents such as articles, papers, or notes. Use `codebase-wiki` when the source is a Git repository and every claim must point to code, tests, or an approved requirement.

## Usage

`/codebase-wiki <ACTION> [ARGUMENTS]`

## Actions

- **init [DIRECTORY]** - Analyze the repository and generate the initial wiki (default: `wiki/`)
- **sync [RANGE]** - Update the pages that Git changes affect (default: last synced commit to `HEAD`)
- **query <QUESTION>** - Answer a feature question with code evidence
- **verify <FEATURE | REQ-ID>** - Compare requirements, implementation, and test evidence
- **impact [RANGE | PR | FILES]** - Identify features that a code change affects
- **lint** - Detect stale pages, broken code references, and unsupported claims
- **status** - Report feature coverage and verification gaps

---

## Architecture

```
wiki/
├── AGENTS.md         # Schema: conventions and per-action workflows (from templates/schema.md)
├── index.md          # Catalog of every page with a one-line summary
├── overview.md       # What the system does, for whom, and its main parts
├── log.md            # Append-only record of every action, with commit SHAs
├── architecture/     # Modules, layers, runtime topology
├── features/         # One page per business feature (from templates/feature.md)
├── business-rules/   # Approved requirements, grouped by domain, with REQ IDs
├── data-models/      # Entities, schemas, state machines
├── integrations/     # External services, queues, webhooks, third-party APIs
├── decisions/        # Links to ADRs or short decision records
└── verification/     # Verification reports (from templates/verification.md)
```

There is no `raw/` directory. Do not copy source code into the wiki. Git is the source history: cite files, symbols, and line ranges at a commit SHA.

Templates are in `$SKILL_PATH/templates/`. `$SKILL_PATH/scripts/evidence.sh` runs the Git checks that have one right answer: the dirty-tree check, staleness, sync coverage, the checkpoint, and ignored-file hashes. Use its output; do not rebuild these checks by hand. `evidence.sh help` explains every output line. It needs only Bash and Git.

---

## Evidence rules

These rules apply to every action. They are the reason this skill exists.

1. **Every claim has a state.** Use exactly one of:

   | State        | Meaning                                                           | Required evidence                                            |
   | ------------ | ----------------------------------------------------------------- | ------------------------------------------------------------ |
   | **Observed** | The source code shows it.                                         | File reference (`path:line` or `path#symbol`)                |
   | **Verified** | An executed test on a clean tree shows it.                        | Test ID, the command that ran it, the result, and its commit |
   | **Inferred** | Reasoned from names, docs, or patterns, not confirmed in code.    | The basis for the inference                                  |
   | **Unknown**  | Not established.                                                  | The open question                                            |
   | **Stale**    | The page's evidence set changed after the commit the claim cites. | The commit range or the uncommitted files that changed it    |

2. **Verified needs an executed test at a clean commit.** Reading a test file only makes the claim Observed. Use Verified only when you ran the test on a clean working tree (rule 3), or when CI results for that exact commit show the test passed. Record the command or the CI run link, and record that commit as `verified_at`.
3. **A dirty tree is not a commit.** Before and after the tests, run `evidence.sh dirty --wiki <wiki-dir> --evidence <path1> --evidence <path2> ...`, with one `--evidence` flag for each of the page's `sources`, `depends_on`, and test paths. Exit 1 means dirty. Two cases need your judgment: a build output such as `dist/` blocks when the tests use it and this run did not rebuild it from the cited commit; and a test command that changed a tracked file, such as a snapshot update, makes the run dirty. A dirty result belongs to the working tree, not to `HEAD`: record it as `dirty (base <short-sha>)` with the `BLOCK` lines. It never makes a claim Verified, a scenario Passed or Failed, or a requirement Met. Report it as provisional and ask the user to commit or stash. Claims also cite a commit, so read files in the evidence set from that commit: when a file has uncommitted changes, read it with `git show <sha>:<path>`, or list it as dirty.
4. **Expected behavior comes from requirements, not from code.** Expected behavior cites a REQ ID in `business-rules/`. When the code does something different, record a mismatch. Do not edit the expected behavior to match the code. A human decides whether the code or the requirement is wrong.
5. **Requirements are human-approved.** When you find a rule with no requirement, add a draft REQ ID with state Inferred and `approved: no`. Do not mark it approved yourself. Set `Approved: yes` only with a citation of who approved it and when: the user confirmed it in this session, or the source document records the approval (for example a spec with its owner, version, and date). Never write `Approved: yes (assumed)`. When you are not sure that a source counts as approval, keep `Approved: no` and ask the user. A draft requirement is never Met, even when every test passes.
6. **Every page records two commits and an evidence set.**
   - `checked_at`: the commit at which the claims were last read against the code.
   - `verified_at`: the clean commit at which the page's tests last ran. Each Verified claim and each test result keeps its own commit.
   - `sources`: the files the page cites. `depends_on`: plain paths of what those files rely on outside the page, such as imported modules, shared middleware and utilities, environment and config files, lockfiles, and database migrations or schemas.

   Updating `checked_at` never changes `verified_at` or the commit of an earlier test result. Do not move test evidence to a newer commit without a new run.
7. **Staleness covers the whole evidence set.** Run `evidence.sh stale <page>`. Exit 1 means Stale, and exit 3 means incomplete: `STALE observed` lines apply to claims that cite `checked_at`, and `STALE verified` lines to claims and scenario results that cite `verified_at`. Keep `depends_on` as plain paths, and record ignored files that the sources rely on (such as `.env.test`) in `ignored_hashes` with `evidence.sh hash <path>...`. A test result with its own commit older than `verified_at` uses that commit: `git diff --name-only <sha> HEAD -- <paths>`. `INCOMPLETE` means the staleness check is incomplete: say so, and do not call the page current.
8. **Scenarios use Passed, Failed, or Untested.** Passed and Failed need a clean test run, as in rule 2, that is not Stale under rule 7. A scenario with no test, with a test you did not run, or with a Stale result is Untested. Keep the last result and its commit in the Last run column, so the history stays visible.
9. **Do not guess.** When evidence is missing, write Unknown and the open question. An honest gap is better than a confident claim with no evidence.

### Example feature

```markdown
# Order Cancellation

Requirements: REQ-ORDER-003 · checked_at: 4f2a9c1 · verified_at: 4f2a9c1
depends_on: src/auth/session.ts, src/db/orders.ts, migrations/

## Expected behavior

Customers can cancel their own unfilled orders. (REQ-ORDER-003)

## Actual implementation

- `cancelOrder` checks ownership before it changes state. — Observed (`src/orders/cancel.ts:18`)
- Filled orders are rejected with `ORDER_ALREADY_FILLED`. — Verified (`cancel.test.ts` › "rejects filled order", `bun test src/orders`, 4f2a9c1)

## Verification scenarios

| Scenario                 | Requirement   | Test                                  | Status   | Last run         |
| ------------------------ | ------------- | ------------------------------------- | -------- | ---------------- |
| Cancel open order        | REQ-ORDER-003 | cancel.test.ts › cancels open order   | Passed   | Passed @ 4f2a9c1 |
| Reject unauthorized user | REQ-ORDER-003 | cancel.test.ts › rejects other user   | Passed   | Passed @ 4f2a9c1 |
| Reject filled order      | REQ-ORDER-003 | cancel.test.ts › rejects filled order | Passed   | Passed @ 4f2a9c1 |
| Concurrent execution     | REQ-ORDER-003 | none                                  | Untested | never            |

## Known risks

- Race between cancel and order execution: no lock or version check in `src/orders/cancel.ts`. — Observed
```

---

## For "init [DIRECTORY]":

1. Confirm the working directory is a Git repository. Record `git rev-parse HEAD` as the initial `checked_at`.
2. If DIRECTORY already exists and is not empty, stop. Ask the user for another directory. Do not merge into or overwrite an existing wiki, including an `llm-wiki` wiki.
3. Find the stack, entry points, routes or commands, domain modules, data models, integrations, and the test runner with its command. Find requirement sources: PRDs, specs, issues, ADRs, and READMEs.
4. List candidate features (user-facing capabilities, not modules) with their main files. Show the list to the user, ask which features to document first, and stop until they answer. Do not create the wiki before then. For a large repository, start with at most 10.
5. Create the directory structure. Copy `$SKILL_PATH/templates/schema.md` to `DIRECTORY/AGENTS.md` and fill in the project section.
6. Write `overview.md`, pages in `architecture/`, `data-models/`, and `integrations/`, and one page per selected feature from `$SKILL_PATH/templates/feature.md`. Apply the evidence rules. Fill in `depends_on` for each page from the imports of its sources and from the shared middleware, config, lockfiles, and migrations they use. Record ignored files in `ignored_hashes` with `evidence.sh hash`. Leave `verified_at` empty until a clean test run. For requirements taken from a spec, set `Approved: yes` only as evidence rule 5 allows, and list every requirement you left `Approved: no` for the user to confirm. Put approved requirements in `business-rules/<domain>.md`. Put rules you found without an approved source there as drafts.
7. Write `index.md` with every page and a one-line summary.
8. Append to `log.md`: `## [YYYY-MM-DD] init | <short-sha> | <N> features`.
9. Tell the user to review the draft requirements and to run `/codebase-wiki verify <feature>` next.

**Done when:** the user has chosen the features, and every selected feature has a page with all template sections, every claim has a state and evidence, every page has `checked_at`, and `index.md` and `log.md` are written.

---

## For "sync [RANGE]":

1. Find the checkpoint with `evidence.sh checkpoint --wiki <wiki-dir>`. The default range is `<checkpoint>..HEAD`.
2. Run `evidence.sh range --wiki <wiki-dir> <start>..<end>` for the `TOUCHED` files, and `evidence.sh dirty --wiki <wiki-dir>`: pages whose evidence set has uncommitted changes are affected too. Mark their claims and scenarios Stale, and do not attribute what you read in those files to a commit (rule 3).
3. Find affected pages: pages whose `sources` or `depends_on` list a changed file, and pages that cite a symbol the diff changed (`rg` the wiki for the file path and the symbol names). For changed files that no page lists, follow importers and callers as in `impact` step 2.
4. For each affected page, read the changed code and update the claims in Actual implementation, Known risks, and Source references. Fix moved or renamed references and update `depends_on`. Mark claims you did not recheck as Stale.
5. Sync does not need a test run. If you do not rerun the tests, keep `verified_at` and each scenario's Last run. Set the Status of a scenario whose evidence set changed to Untested, and mark its Verified claims Stale. Do not delete or re-date the earlier result.
6. Do not change Expected behavior. If the new code contradicts a requirement, add a mismatch to the page and to the sync report.
7. Add new feature pages for new user-facing capabilities. Mark pages for deleted features `status: removed` instead of deleting them.
8. Update `checked_at` on each page you rechecked, and update `index.md`.
9. Log the range from the `COVERS` line of step 2. `COVERS yes`: append `## [YYYY-MM-DD] sync | <start>..<end> | <N> pages`, which moves the checkpoint to `<end>`. `COVERS no`: append `## [YYYY-MM-DD] sync-partial | <start>..<end> | <N> pages`, which leaves the checkpoint where it was, and report the `REASON` and the `UNSYNCED` commits.
10. Report the changed pages, new mismatches, scenarios set to Untested, and open risks for human review.

**Done when:** every page whose evidence set changed is rechecked or marked Stale, no test result has moved to a commit it did not run at, the log entry is `sync` only when the range covers everything since the checkpoint, and the report lists every behavior change and mismatch.

---

## For "query <QUESTION>":

1. Read `index.md` and the relevant pages.
2. For each page you use, run `evidence.sh stale <page>` (evidence rule 7). If it exits 1 (Stale) or 3 (incomplete), read the current code before you answer, and say that the page is stale or that its check is incomplete.
3. Answer with file references and claim states. Say what is Verified, what is only Observed, and what is Unknown.
4. If the answer adds knowledge that the wiki does not have, offer to add it to the page. If the user agrees, update the page, `index.md`, and `log.md`.

**Done when:** the answer cites code or test evidence for each claim, states each claim's state, and reports stale pages.

---

## For "verify <FEATURE | REQ-ID>":

1. Collect the requirements for the target from `business-rules/` and the feature page. Note which ones are `approved: no`.
2. **Derive the acceptance scenarios before you read the tests.** From the text of each requirement only, list the scenarios that would show it holds: the main path, authorization, invalid input and boundaries, error paths, and concurrency or ordering where the requirement depends on state. Write them in the report. Passing tests alone do not show that a requirement is covered.
3. For each requirement, find the implementation (Observed, with file references). Then map existing tests to the derived scenarios. A scenario with no matching test is Untested. A test that matches no scenario does not count as coverage.
4. Check the tree with `evidence.sh dirty` as in evidence rule 3, before and after the test run. If the tree is dirty at either check, follow rule 3: you can run the tests for a provisional result, but no scenario becomes Passed or Failed. Otherwise run the relevant tests with the project's existing test runner. When the project can run there, run them in a fresh `git worktree` checked out at the clean commit, so edits in the main checkout during the run cannot reach the tested code. Run `evidence.sh dirty` inside the worktree too, before and after the tests, because a test that changes a tracked file there does not show in the main checkout. A fresh worktree has no ignored files, so copy in the ignored inputs the tests need, such as `.env.test`, and record them with `evidence.sh hash`; if you cannot, run in place. When you run in place, rely on both tree checks in the main checkout. They do not see an edit that another process, such as an editor or another agent, makes and reverts during the run: run in place only when nothing else writes to the checkout, or record the result as provisional. The checks also do not protect against a test command that edits tracked source and restores it before it exits, such as a mutation tester, a code generator, or a fixture swap restored in teardown. If the test command does that, the result is provisional, as in rule 3, unless you can show the tested source matched the commit, for example by running on a read-only checkout. Record the command, the clean commit, and the result of each test.
5. Fill in a report from `$SKILL_PATH/templates/verification.md` at `verification/<feature>-<YYYY-MM-DD>-<short-sha>.md`. If that file already exists, add `-2`, `-3`, and so on. Never overwrite an earlier report. Give each requirement one verdict:
   - **Met**: the requirement is approved, the implementation matches, it has at least one derived scenario, and every derived scenario Passed in a clean run.
   - **Not met**: the implementation contradicts the requirement, or a test run on a clean tree does. A failing test from a dirty tree alone does not make it Not met.
   - **Unverified**: nothing contradicts the requirement, but it is a draft, it has no scenario, at least one scenario is Untested, or the run was on a dirty tree.
6. Update the feature page: scenario statuses and Last run, claim states, `checked_at`, `verified_at`, and a link to the report. After a dirty run, leave `checked_at` and `verified_at` unchanged and record the dirty base in the report only.
7. Append to `log.md`: `## [YYYY-MM-DD] verify | <feature> | <short-sha> | <met>/<total> met`.
8. Report every Not met and Unverified requirement with its reason, the derived scenarios that have no test, and new risks.

**Done when:** every requirement has a verdict with evidence, the derived scenarios are in the report, no draft requirement is Met, no dirty run counts as verification, the report and feature page are updated, and the gaps are reported. If the tests cannot run, report that. Leave the affected requirements Unverified, except those the implementation contradicts, which stay Not met.

---

## For "impact [RANGE | PR | FILES]":

This action is read-only. It does not edit the wiki.

1. Get the changed files and symbols from the range, the PR diff (`gh pr diff`), or the file list. The default is the uncommitted and staged changes.
2. Map them to features in two passes:
   - **Direct:** pages whose `sources` list a changed file or cite a changed symbol.
   - **Indirect:** for each changed file, find its importers and the callers of its changed symbols with `rg` (import statements and symbol names). Repeat on the files you find until you reach a page's `sources` or an entry point. Also check shared configuration that applies to many features without an import: middleware and route registration, dependency injection, environment and config files, lockfiles, and database migrations or schemas. Match pages whose `depends_on` list the changed file. Follow links from `data-models/` and `integrations/` pages to features.
3. For each affected feature, give the path that links it to the change (for example `src/middleware/auth.ts` → `app.use(auth)` in `src/server.ts` → `/orders/:id/cancel`), the requirements and scenarios at risk, and the tests to run.
4. Call a feature unaffected only after both passes find no path. If a search is incomplete, for example dynamic imports or reflection, say so and list the feature as possibly affected.
5. List changed files that no page cites and no path reaches. These are coverage gaps.

**Done when:** the report lists each directly and indirectly affected feature with its path, requirements, and tests to run, and the changed files that no page covers. Offer `sync` after the change merges.

---

## For "lint":

Check the whole wiki and report each issue type:

- **Broken code references**: cited files that do not exist at `HEAD`, or cited symbols that `rg` cannot find.
- **Stale pages**: pages where `evidence.sh stale` exits 1. List pages where it exits 3 separately, as incomplete checks, not as Stale.
- **Unsupported claims**: claims with no state, Observed claims with no file reference, Verified claims with no test run record or with a dirty-tree run, and Passed or Failed scenarios whose Last run is Stale or was on a dirty tree.
- **Requirement gaps**: requirements with no feature page, features with no requirement, draft requirements still not approved, draft requirements marked Met, and open mismatches.
- **Test gaps**: requirements with no scenario, and Untested or Failed scenarios.
- **Structure**: pages missing from `index.md`, orphan pages, and broken wiki links.

Ask before you fix anything. Append to `log.md`: `## [YYYY-MM-DD] lint | <short-sha> | <N> issues`.

**Done when:** all six issue types are checked and reported with file and page references, and the log entry is appended.

---

## For "status":

Report:

- Feature count, pages Stale against `HEAD` (`evidence.sh stale` exits 1), and pages whose check is incomplete (exits 3), listed separately and not counted as current
- Claim counts by state (Observed, Verified, Inferred, Unknown, Stale)
- Scenario counts by status (Passed, Failed, Untested)
- Requirements by verdict, and requirements with no test
- The checkpoint (`evidence.sh checkpoint --wiki <wiki-dir>`), how many commits `HEAD` is ahead of it, and any `sync-partial` ranges after it
- The last 5 entries in `log.md`

**Done when:** all six items are reported.

---

## Workflow fit

```
human approves requirements → agent implements → independent agent evaluates requirements and tests
→ CI verifies → codebase-wiki sync/verify updates knowledge and evidence
→ human reviews behavior changes and open risks → release
```

The wiki does not approve requirements or releases. It records evidence and puts mismatches and risks in front of a human.

## Optional: GitHub Actions

To keep the wiki current, run the agent with `/codebase-wiki sync` and `/codebase-wiki lint` on pushes to the default branch, then open a pull request with the wiki changes for human review. Run `/codebase-wiki impact <PR>` on pull requests and post the result as a comment. Use the agent CLI and credentials that the project already uses in CI. Do not commit wiki changes directly to the default branch.

## Scope

The MVP uses only Markdown, Git, and the project's existing test runners. Do not add a vector database, graph database, MCP server, or web app.

Files in this skill

  • SKILL.md22.5 KB
  • evals/evals.json9.6 KB
  • evals/results.md9.8 KB
  • scripts/evidence.sh14.1 KB
  • templates/feature.md2.5 KB
  • templates/schema.md7.8 KB
  • templates/verification.md3.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.