agentleFS
imMamdouhaboammarimMamdouhaboammar/repo-to-skill/skills/codebase-constitution/SKILL.md

codebase-constitution

Skill0 starsChanged 51 days agoMITView on GitHub

Two-stage unified microservices engine that reverse-engineers any codebase into an engineering constitution and synthesizes an operational agent skill end-to-end automatically. Step 1 (codebase-constitution) extracts architecture decisions, invariants, conventions, technology contracts, and implicit ADRs from code evidence. Step 2 (repo-to-skill) takes that domain knowledge and synthesizes an operational skill package with SKILL.md, references, deterministic scripts, and benchmark evals. Use when asked to "reverse-engineer this codebase into a constitution", "turn this repo into an agent skill", "extract engineering principles", "produce an ADR backlog", "skillify this project", or generate living agent instructions from a repository.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every architecture claim cites a verified file path.

    line 144
  2. Distinctive:

    Every invariant cites the concrete code enforcing it.

    line 145
  3. Distinctive:

    Every ADR names the evidence source (file, commit, or comment).

    line 146

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- ╔═════════════════════════════════════════════════════════════════════════════╗ ║ CODEBASE CONSTITUTION & SKILL SYNTHESIS ENGINE ║ ║ ║ ║ Copyright (c) 2026 Mamdouh Aboammar. All rights reserved. ║ ║ Licensed under the MIT License. ║ ║ Repository: github.com/imMamdouhaboammar/codebase-constitution ║ ╚═════════════════════════════════════════════════════════════════════════════╝ -->

Codebase Constitution & Skill Synthesis Engine

Two-stage microservices system: reverse-engineer any codebase into an engineering constitution and synthesize an operational agent skill — 100% automated end-to-end.

Author: Mamdouh Aboammar · License: MIT · Version: 1.1.0

$$\text{Raw Codebase} \xrightarrow{\text{Stage 1: Constitution Engine}} \begin{pmatrix} \text{Topology} \ \text{Invariants} \ \text{ADRs} \ \text{Conventions} \end{pmatrix} \xrightarrow{\text{Stage 2: Skill Synthesizer}} \begin{pmatrix} \text{SKILL.md} \ \text{References} \ \text{Evals Benchmark} \ \text{Host Adapters} \end{pmatrix}$$


When to activate

Activate on requests like:

  • "reverse-engineer this codebase into a constitution"
  • "turn this repo into an agent skill"
  • "extract engineering principles and create a skill for this project"
  • "generate a CONSTITUTION.md and skill package from this repo"
  • "produce an ADR backlog and agent rules from code"
  • "skillify this repository"
  • "what are the invariants in this system?"

Do NOT activate on:

  • "explain this single function" → use code-explainer
  • "fix this bug" → use ce-debug
  • "review this PR" → use agency-code-reviewer

The Two-Stage Automated Pipeline

┌─────────────────────────────────────────────────────────────────────────────┐
│  STAGE 1: CONSTITUTION ENGINE (codebase-constitution)                       │
│  ├─ PASS 1: Topology Harvest        → language mix, entry points, test ratio│
│  ├─ PASS 2: Dependency Audit        → package manager, version locks        │
│  ├─ PASS 3: Architecture Extraction → layers, boundaries, communication     │
│  ├─ PASS 4: Decision Archaeology    → implicit ADRs from comments & git log │
│  ├─ PASS 5: Invariant Distillation  → MUST-NEVER / MUST-ALWAYS / MUST-WHEN  │
│  ├─ PASS 6: Convention Codification → naming, errors, testing conventions   │
│  └─ PASS 7: Agent Rule Synthesis    → machine-readable agent-rules.yaml     │
└──────────────────────────────────────┬──────────────────────────────────────┘
                                       │ (Piped domain facts & invariants)
                                       ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│  STAGE 2: SKILL SYNTHESIZER (repo-to-skill)                                 │
│  ├─ Tool Classification             → CLI, Library, Framework, or Service  │
│  ├─ Operational SKILL.md            → compact (<500 lines), imperative steps│
│  ├─ Progressive References          → API reference, examples, config docs │
│  ├─ Verification Smoke Test         → executes help, install, and core paths│
│  └─ Benchmark Evaluation            → evals.json with binary assertions     │
└─────────────────────────────────────────────────────────────────────────────┘

Both stages execute in a single sequence without requiring human intervention.


Command Invocation

# Analyze and synthesize in one shot:
npx codebase-constitution run <repo-url-or-local-path> [--out <output-dir>]

# Install skill package across all agent hosts on your machine:
npx codebase-constitution install

Output Contract

Executing the pipeline produces:

dist/
├── docs/
│   ├── CONSTITUTION.md        # The 10-section engineering constitution
│   ├── topology.yaml          # Language breakdown & package manifest audit
│   ├── agent-rules.yaml       # Machine-readable behavioral rules
│   └── adr/
│       ├── ADR-000.md         # ADR index
│       └── ADR-*.md           # Discovered implicit decisions with evidence
└── skills/
    └── <project-name>/
        ├── SKILL.md           # Operational agent execution guide
        ├── references/
        │   ├── api-reference.md
        │   ├── examples.md
        │   └── configuration.md
        ├── evals/
        │   └── evals.json     # Benchmark test prompts and assertions
        └── adapters/          # Antigravity, Claude, Codex, Cursor, Universal

Evidence Invariants

  • Every architecture claim cites a verified file path.
  • Every invariant cites the concrete code enforcing it.
  • Every ADR names the evidence source (file, commit, or comment).
  • Zero hallucination of git commit SHAs or non-existent symbols.
  • Agent rules must derive from codebase evidence, never generic templates.

Copyright (c) 2026 Mamdouh Aboammar. All rights reserved. MIT License.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.