| name | code |
| description | Executable documentation governance with compound engineering and abductive learning. Enforces the Seven Laws through type compilation, schema validation, and hookify-based enforcement. Implements programmatic compound engineering where K' = K โช crystallize(assess(ฯ)) for monotonic knowledge growth. Integrates abstracted abductive learning (OHPT protocol) for systematic debugging and pattern extraction. Trigger when writing code, debugging, establishing governance, or when mentioned vibecode, compound, abductive, or executable documentation. Self-validating and homoiconic. |
| allowed-tools | Read, Write, Edit, Grep, Glob, Bash |
| model | sonnet |
| context | fork |
| agent | code-governance-agent |
| user-invocable | true |
Code: Executable Documentation Governance
ฮปฮฟ.ฯ :: Vibecode โ ExecutableDocumentation
where ฯ โ {compiles, validates, runs, passes}
compound :: Knowledge โ Response โ Knowledge
compound K ฯ = K โช crystallize(assess(ฯ))
Metaschema
This skill is homoiconic: it enforces the same patterns it describes. The structure mirrors the content; the DAG below governs both skill loading and project governance.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PROGRESSIVE LOADING DAG โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ L0: SKILL.md (this file) โ
โ โ โข Core laws, routing, quick patterns โ
โ โ โข Compound engineering integration โ
โ โ โข Always loaded (~500 lines) โ
โ โ โ
โ โโโโบ L1: references/laws.md โ
โ โ โข Seven Laws complete specification โ
โ โ โข Load when: implementing governance โ
โ โ โ
โ โโโโบ L1: references/executable-doc.md โ
โ โ โข Tier hierarchy, conversion methodology โ
โ โ โข Load when: converting docs to code โ
โ โ โ
โ โโโโบ L1: references/patterns.md โ
โ โ โข TODO management, type documentation โ
โ โ โข Load when: establishing patterns โ
โ โ โ
โ โโโโบ L1: references/compound-engineering.md โ
โ โ โข K' = K โช crystallize(assess(ฯ)) โ
โ โ โข Load when: crystallizing learnings โ
โ โ โ
โ โโโโบ L1: references/abductive-learning.md โ
โ โ โข OHPT protocol for debugging โ
โ โ โข Load when: systematic debugging needed โ
โ โ โ
โ โโโโบ L2: scripts/preflight.py โ
โ โ โข Execute directly for validation โ
โ โ โข Load when: customizing checks โ
โ โ โ
โ โโโโบ L2: scripts/validate-skill.py โ
โ โ โข Self-validation (homoiconic) โ
โ โ โข Load when: validating this or other skills โ
โ โ โ
โ โโโโบ L2: hooks/* โ
โ โ โข Hookify rules for governance + compound learning โ
โ โ โข Install via: scripts/install-hooks.sh โ
โ โ โ
โ โโโโบ L3: templates/* โ
โ โข CI/CD configs โ
โ โข Copy when: initializing projects โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The Seven Laws
-- Core invariants (see references/laws.md for complete spec)
LAW_1: โf โ Features. deployed(f) โน e2e_verified(f)
LAW_2: โe โ Executions. observable(e) โง traceable(e)
LAW_3: โr โ CriticalRules. script_enforced(r)
LAW_4: โpr โ PRs. merged(pr) โน human_reviewed(pr)
LAW_5: โd โ AuthoritativeDoc. d โ Codebase
LAW_6: compiles(d) โจ validates(d) โน current(d)
LAW_7: โplan โ Plans. expressed_as_todos(plan) โง in_code(plan)
Routing
def route(task: Task) -> Pipeline:
"""Route task to appropriate governance level."""
if task.type == "simple_change":
return R1_SINGLE
if task.type == "feature":
return R2_COMPOSE
if task.type in ["architecture", "governance", "release"]:
return R3_FULL
return R0_DIRECT
| Level | Pipeline | Verification |
|---|
| R0 | Direct | None |
| R1 | preflight | Types, schemas, linting |
| R2 | preflight โ e2e โ logs | + Runtime behavior |
| R3 | full_governance | All Seven Laws |
Quick Start
1. Initialize Project Governance
cp templates/ci.yml ./.github/workflows/
python scripts/preflight.py --init
bash scripts/install-hooks.sh
2. Establish Executable Documentation
@dataclass
class UserResponse:
"""User endpoint response. If this compiles, docs are current."""
name: str
email: EmailStr
created_at: datetime
3. Plan with TODOs
async def login(credentials: LoginCredentials) -> AuthResult:
pass
4. Validate Before Merge
python scripts/preflight.py
grep -rn "TODO(.*required" --include="*.py" --include="*.ts" src/
npx madge --image docs/deps.svg src/
Executable Documentation Hierarchy
| Tier | Form | Trust | Verification |
|---|
| T1 | Type signatures | 0.95 | Compiler |
| T2 | Schema definitions | 0.95 | Validator |
| T3 | API specs (generated) | 0.95 | Generator |
| T4 | Database migrations | 0.95 | Migration runner |
| T5 | Linter rules | 0.90 | Linter |
| T6 | Test assertions | 0.70 | Test runner |
| T7 | TODOs in code | 0.60 | Grep/lint |
| T8 | Inline comments | 0.50 | Localized drift |
| T9 | External docs | 0.10 | Will drift |
Governing Principle:
IF types check (T1)
AND schemas validate (T2)
AND specs generate (T3)
AND migrations run (T4)
AND linters pass (T5)
AND todos resolved (T7)
THEN documentation IS current
Conversion Methodology
When documentation is needed, convert to code-based form:
def document_in_code(need: str) -> CodeDoc:
"""Convert documentation need to executable form."""
if can_express_as_type(need):
return TypeDefinition(need)
if can_express_as_schema(need):
return SchemaDefinition(need)
if can_express_as_linter_rule(need):
return LinterRule(need)
if can_express_as_test(need):
return TestCase(need)
if can_express_as_todo(need):
return TODO(need)
return InlineComment(need)
For complete conversion patterns, load: references/executable-doc.md
Preflight Script
Core validation that runs before every commit:
#!/bin/bash
set -e
echo "=== PREFLIGHT: Executable Documentation Verification ==="
npm run typecheck || { echo "โ Types invalid"; exit 1; }
npm run validate:schemas || { echo "โ Schemas invalid"; exit 1; }
npm run lint || { echo "โ Linting failed"; exit 1; }
grep -rn "TODO(.*required" src/ && { echo "โ Required TODOs remain"; exit 1; }
echo "โ
Preflight passed"
For complete preflight implementation, run: python scripts/preflight.py
TODO Categories
Lifecycle:
PLAN โ Write TODOs at implementation points
DEVELOP โ Implement, remove TODO when done
VERIFY โ grep for remaining TODOs
COMPLETE โ Zero required TODOs = feature complete
For TODO management, use: grep -rn "TODO(.*required" --include="*.py" --include="*.ts" src/
Unit Test Skepticism (LAW_3 Caveat)
def authenticate(user, password):
return True
def test_authenticate():
assert authenticate("user", "pass") == True
Mitigation:
- E2E tests verify actual behavior (LAW_1)
- Human review verifies intent (LAW_4)
- Unit tests provide regression protection only
- Trust hierarchy:
E2E (0.9) > Review (0.75) > Unit (0.3)
Diagram Generation
Generate diagrams from code, never hand-draw:
npx madge --image docs/deps.svg src/
npx ts-diagram src/ > docs/types.mmd
pg_dump --schema-only | sqlt-graph > docs/schema.svg
npm run generate:openapi
Use standard tools: npx madge, npx ts-diagram, pg_dump | sqlt-graph
Self-Validation (Homoiconicity)
This skill validates itself using the same rules it prescribes:
Run: python scripts/validate-skill.py code/
Compound Engineering
The self-improvement loop that makes knowledge recursive:
compound :: Knowledge โ Response โ Knowledge
compound K ฯ = K โช crystallize(assess(ฯ))
-- K grows monotonically; never loses valid knowledge
-- Crystallization compresses: raw experience โ reusable pattern
The Compound Loop
Plan(K) โ Execute โ Assess โ Compound(KโK')
โ |
โโโโโโโโโโโ K' โโโโโโโโโโโโโโโโโ
Each iteration makes the next easier, not harder.
Trigger Detection
Compound when resolution patterns detected:
| Pattern | Example | Action |
|---|
| Confirmation | "that worked", "correct" | Extract solution |
| Insight | "I see now", "the key is" | Extract principle |
| Prevention | "next time", "to avoid" | Extract guard |
| Connection | "this relates to", "like" | Extract vertex |
Learning Crystallization
date: YYYY-MM-DD
trigger: "what initiated learning"
domain: "coding|debugging|architecture|..."
observation: "what was observed"
hypothesis: "best explanation"
root_cause: "fundamental cause (not surface)"
solution: "what worked"
why_works: "mechanistic explanation"
prevention: "how to avoid in future"
vertices:
- "[[shared concept 1]]"
- "[[shared concept 2]]"
confidence: 0.85
Validation before adding to K:
For complete compound engineering spec, load: references/compound-engineering.md
Abductive Learning (OHPT Protocol)
Inference to the best explanation for systematic debugging:
O (Observation) โ H (Hypothesis) โ P (Prediction) โ T (Test)
| Phase | Question | Output |
|---|
| O | What was observed? | Symptom description |
| H | What explains O? | Candidate causes (ranked by parsimony) |
| P | If H true, what else? | Testable predictions |
| T | Does P hold? | Evidence confirming/refuting H |
Quick Template
"""
O: [What was observed - be specific]
H: [Best explanation - testable, parsimonious]
P: [If H true, then... - observable consequences]
T: [Test result - confirms/refutes H]
"""
For complete OHPT protocol, load: references/abductive-learning.md
Hookify Integration
Governance enforcement through hookify rules:
| Hook | Event | Purpose |
|---|
law1-e2e-deploy | bash | Verify E2E before deploy |
law2-observability | file | Warn on debug logging |
law5-external-docs | file | Block external documentation |
law6-compile-current | bash | Check types before merge |
law7-required-todos | bash | Verify TODOs resolved |
stop-checklist | stop | Seven Laws completion check |
tautological-tests | file | Detect test anti-patterns |
compound-learning | stop | Prompt crystallization |
abductive-hypothesis | file | Require OHPT in tests |
knowledge-monotonicity | file | Prevent knowledge deletion |
vertex-sharing | file | Require vertex connections |
inference-chain | file | Complete reasoning chains |
pattern-crystallization | bash | Extract on commits |
Install hooks: bash scripts/install-hooks.sh
Integration Points
| Skill | Integration |
|---|
graph | Topology validation (ฮท โฅ 4) |
critique | Multi-lens code review |
hierarchical-reasoning | SโTโO decomposition |
component | Generate CI/CD configs |
skill-optimiser | Validate this skill |
learn | Compound engineering loop |
ultrawork | Parallel governance checks |
File Structure
code/
โโโ SKILL.md # This file (L0)
โโโ references/
โ โโโ laws.md # Seven Laws complete spec (L1)
โ โโโ executable-doc.md # Tier system, conversion (L1)
โ โโโ patterns.md # TODO, types, diagrams (L1)
โ โโโ compound-engineering.md # K' = K โช crystallize(assess(ฯ)) (L1)
โ โโโ abductive-learning.md # OHPT debugging protocol (L1)
โโโ scripts/
โ โโโ preflight.py # Validation orchestration (L2)
โ โโโ validate-skill.py # Self-validation (L2)
โ โโโ install-hooks.sh # Install governance hooks (L2)
โโโ templates/
โ โโโ ci.yml # GitHub Actions template (L3)
โโโ hooks/ # Hookify governance + compound rules
โโโ hookify.law1-e2e-deploy.local.md
โโโ hookify.law2-observability.local.md
โโโ hookify.law5-external-docs.local.md
โโโ hookify.law6-compile-current.local.md
โโโ hookify.law7-required-todos.local.md
โโโ hookify.stop-checklist.local.md
โโโ hookify.tautological-tests.local.md
โโโ hookify.compound-learning.local.md # Crystallize before stop
โโโ hookify.abductive-hypothesis.local.md # OHPT in tests
โโโ hookify.knowledge-monotonicity.local.md # K never shrinks
โโโ hookify.vertex-sharing.local.md # Require connections
โโโ hookify.inference-chain.local.md # Complete reasoning
โโโ hookify.pattern-crystallization.local.md # Extract on commit
Holarchic Structure
Every component is a complete holon:
SKILL (this file)
โโโ Contains: Complete governance framework
โโโ Validates: Itself via scripts/validate-skill.py
โโโ Holons:
โโโ preflight.py
โ โโโ Contains: Complete validation pipeline
โ โโโ Validates: Project code
โ โโโ Holons: Individual check functions
โ
โโโ hooks/*
โ โโโ Contains: Seven Laws enforcement rules
โ โโโ Validates: Via hookify plugin
โ โโโ Holons: Individual law-specific rules
โ
โโโ templates/*
โโโ Contains: Complete project setup
โโโ Validates: Via instantiation
โโโ Holons: Individual config files
Scale invariance: ฮปฮฟ.ฯ applies at every levelโskill, script, function, line.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SEVEN LAWS โ TRUST HIERARCHY โ VERIFICATION โ
โโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค
โ 1. E2E verified โ Types (0.95) โ Compiles โ
โ 2. Observable โ Schemas (0.95) โ Validates โ
โ 3. Script enforced โ E2E (0.90) โ Passes โ
โ 4. Human reviewed โ Review (0.75) โ Approved โ
โ 5. Code is doc โ Unit (0.30) โ (Low trust) โ
โ 6. Compile=current โ External (0.10) โ (Will drift) โ
โ 7. TODOs are plans โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโ