codex/skills/codebase-doctrine/SKILL.md
Compile deep repository evidence into artifact-bound correctness doctrine, authority/law/proof maps, strongest knowledge destinations, and an optional minimal repository-skill portfolio. Use when the user wants both deep codebase understanding and durable doctrine, knowledge routing, or repository-specific skill recommendations. Research discoverable facts before asking; use `$grill-me` only for material user-owned intent choices. Not for quick onboarding, one isolated invariant, ordinary implementation, generic review, or direct skill creation.
npx skillsauth add tkersey/dotfiles codebase-doctrineInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Determine what future maintainers and coding agents must know, decide, reject, and prove to change a repository safely.
Compile:
authorized intent
-> named search questions
-> artifact-bound evidence
-> closed claim graph
-> current/target authorities, laws, invariants, boundaries, failures, and proof
-> strongest knowledge destinations
-> zero or one root skill plus zero to five focused skill candidates
The final doctrine is a canonical synthesis for one pinned repository and intent state. It is not stronger than current code, executable proof, explicit user authority, or canonical domain stores such as the negative ledger.
Use when the request contains both:
deep repository understanding
+
durable correctness doctrine, knowledge routing, authority/proof maps,
or repository-specific skill recommendations
Do not use for:
The skill is read-only. Persistence and skill creation require separate explicit authorization.
Choose exactly one mode:
| Mode | Purpose | Terminal artifact |
|---|---|---|
| survey | Provisional map and exact next questions | codebase_survey / CBS-v1 |
| doctrine | Complete baseline workflow | codebase_doctrine / CBD-v2 |
| deep | Complete baseline plus adaptive specialists | CBD-v2 with specialist receipts |
| refresh | Revalidate an existing doctrine at a new state | codebase_doctrine_delta / CBDD-v1 plus resulting CBD-v2 |
| portfolio | Reevaluate knowledge destinations and skill candidacy | codebase_portfolio / CBP-v1 |
| audit | Compare current guidance and skills with doctrine | codebase_doctrine_audit / CBA-v1 |
Do not force a full CBD into survey, portfolio, audit, or delta work.
doctrine_intent_gate DIG-v2
codebase_doctrine_intent CDI-v2
codebase_doctrine_assignment CBDA-v1
codebase_doctrine_packet CBDP-v2
codebase_doctrine CBD-v2
codebase_doctrine_delta CBDD-v1
codebase_skill_handoff CBSH-v2
DIG plus an optional bounded grill closure deterministically compiles to CDI:
uv run --with pyyaml python \
codex/skills/codebase-doctrine/tools/intent_compile.py \
gate.yaml \
[--grill grill.yaml] \
--output intent.yaml
CBD is a closed evidence graph. Every typed reference must resolve.
Before asking intent questions, inspect enough to distinguish discoverable facts from user-owned choices:
Create DIG-v2 before continuing.
$grill-me dispatch$grill-me may clarify only material user-owned choices such as:
target boundary
consumers
current-state versus target-state posture
desired products
correctness priorities
non-goals
proof bar
compatibility or migration posture
persistence
Do not ask it for repository facts, laws, implementation design, or skill-file content.
When DIG-v2 validates with:
grill_required: yes
gate:
doctrine_may_proceed: no
intent_route:
route: grill-me
hard_stop: yes
next_action: activate_grill_me
then Codebase Doctrine must immediately activate $grill-me in the same turn,
pass only the validated codebase_doctrine_grill_handoff, and hard-stop. Do not
continue repository exploration, synthesize CDI/CBD, ask the questions directly,
or choose defaults. Resume this workflow only after a bound
grill_decision_packet returns plan_allowed: true and resolves every material
DIG gap.
A grill closure must bind to the original DIG and explicitly resolve every
material gap. plan_allowed: true authorizes doctrine inquiry only; it does not
authorize persistence, skill creation, code edits, commit, push, or publication.
CDI records:
CDI does not declare repository-derived laws before research.
After CDI locks the target, pin:
artifact_state:
artifact_state_id:
repository_root:
repository_name:
branch:
head:
dirty_state:
tracked_diff_sha256:
untracked_path_digest:
scope_path_digest:
intent_digest:
scope:
intent_id:
captured_at:
Every evidence item, proof receipt, worker assignment, and worker packet binds to this state.
Re-pin before closure. Reject stale evidence after a relevant head, diff, scope, or intent change.
Codebase Doctrine owns analysis and synthesis. It may consume bounded canonical evidence from:
$seq query-only session/tool/orchestration evidence
$negative-ledger query/export-only canonical route evidence
$retrace bounded replay when consequential rationale is incomplete
$grill-me user-judgment clarification only
These are evidence providers, not competing doctrine owners.
Separate:
fact
inference
recommendation
open question
current observed law
documented intent
explicit user target
proposed law
contradicted or retired doctrine
Determine repository kind, languages, build/test systems, deployment shape, dependency direction, subsystems, public contract roots, entrypoints, and local dialect. Architecture is a hypothesis backed by responsibilities and dependency direction, not directory names.
Trace representative flows:
input or trigger
-> parsing or routing
-> orchestration
-> domain transition
-> persistence or integration
-> output or effect
Record external boundaries, persistence/configuration roots, feedback loops, and delays.
For important state and evidence, identify who may create, mutate, validate, certify, publish, transfer, consume, retire, and roll back it.
Prioritize write paths, transitions, certificates, transactions, and rollback over readers or names.
Use the smallest correctness vocabulary that explains carriers, operations, observations, state classes, transitions, laws, non-laws, forbidden states, and projections.
Do not turn incidental current behavior into doctrine.
Every law records:
Do not merge an observed law and proposed repair law into one unlabelled row.
An invariant requires owner, source of truth, initialization, preserving transitions, violating counterexamples, enforcement boundary, exception owner, and proof.
A boundary requires accepted/rejected inputs, authority before/after, transferred state or evidence, and proof.
Normalize local wounds into recurring law, authority, representation, boundary, or proof-shape failures.
A negative route may be:
suspected
witnessed
canonical_projection
retired
Only a current canonical negative-ledger projection may create durable route exclusion.
Distinguish:
proof design
executed current proof
historical proof
manual or reviewer proof
Executed current proof records command, exit code, result reference, toolchain, target, artifact state, and verification time.
Do not average incompatible claims. Resolve them or preserve the contradiction, stronger evidence, residual uncertainty, and materiality.
Every durable active claim receives exactly one primary destination:
code
type_or_representation
test_or_property
static_tool_or_linter
CI_gate
AGENTS_or_repository_guidance
ADR_or_reference
negative_ledger
repository_root_skill
focused_skill
retain_in_doctrine
reject
Prefer the strongest enforceable destination.
Portfolio shape:
zero or one root repository skill
zero to five focused skills
No skill is required.
Each candidate criterion is an evidence-bearing decision, not a self-attested
boolean. New candidates normally end as recommended_for_trial. accepted
requires empirical use evidence.
Stop when additional search is unlikely to change a material doctrine decision.
A saturated artifact requires:
additional_search_would_change value is no;Never claim exhaustive understanding.
Deep mode uses specialists only for unresolved route-changing questions.
Recommended waves:
Wave 1 codebase_cartographer + authority_state_mapper
Wave 2 behavioral_law_miner / failure_forensics_analyst /
codebase_doctrine_proof_mapper for identified surfaces
Wave 3 doctrine_portfolio_skeptic after draft knowledge routing
Wave 4 search_saturation_auditor after the complete draft
Do not launch all workers merely because mode is deep.
Every worker receives a CBDA-v1 assignment and returns one CBDP-v2 packet bound to its artifact state, scope, question, lane, and update-key authority.
Workers are read-only, cannot spawn children, and never own final doctrine.
The root:
Generate an identity-level delta between two valid doctrines:
uv run --with pyyaml python \
codex/skills/codebase-doctrine/tools/doctrine_diff.py \
prior.yaml new.yaml \
--changed-path src/example.zig \
--output delta.yaml
A delta partitions retained, modified, added, and invalidated IDs; identifies proof rechecks; and exposes intent drift.
Default output is conversational.
Persist only when requested:
.codebase-doctrine/doctrine.yaml
Local-exclude by default unless the user explicitly wants versioned doctrine.
Codebase Doctrine recommends; it does not create.
After explicit user authorization, bind CBSH-v2 to its source CBD and hand it
to $ms.
After generated skills have real use:
$seq skill-decision-audit
-> $tune
-> $refine
Return changed laws or authority to $codebase-doctrine refresh. Do not tune from
raw mention counts.
tools
Invokes Apple's macOS 27 fm command-line tool from a local Mac to use the on-device system model or Private Cloud Compute, including instructions, image prompts, schema-constrained JSON, and noninteractive automation. Use when the user asks to run Apple Foundation Models through fm, compare system versus pcc, generate structured output, or automate fm without Swift or an app.
development
Compile historical Codex sessions into governed counterfactual evidence, evaluate an existing owner-applied candidate through blinded paired HCTP trials, and fold observable evidence into RUN, OBSERVE, or STOP. Use for `$hylo`, CRF extraction, counterfactual replay, source-governed direct or historical trials, sealed evidence, paired baseline/candidate evaluation, causal frontiers, or evidence-governed improvement.
testing
Ensure a `ledger` command is available on PATH; materialize, validate, record, replay, and project requested Actuating artifacts without taking semantic or execution authority; coordinate the shared Learnings/Synesthesia/Negative Ledger lifecycle checkpoint and repo-local source-memory reconciliation; address Universalist plans and receipts; and perform pure artifact validation.
testing
Classify and quotient review findings, failing tests, incidents, bug reports, migration failures, and other witnessed falsifiers against accepted intent and the current Construction. Author counterexample-set/v1 without selecting repairs, counting review credit, or granting mutation.