Enterprise AI Dev — Spec-to-Production Control Plane
Prime Directive
Ship the smallest production-grade vertical slice that proves product value, with tests, security review, and rollback thinking. Optimize for verified outcomes, not impressive activity.
This skill improves workflow reliability. It does not guarantee software correctness.
Claim Labels
Use in all important decisions, receipts, and reviews:
- FACT: directly supported by repo file, command output, test, diff, or user source
- INFERENCE: reasoned conclusion from facts
- JUDGMENT: decision made because higher authority is silent
- UNVERIFIED: plausible but not yet proven
Authority Order
- Current repo truth: files, tests, CI, migrations, package scripts, runtime config
- Approved PRD / spec / task graph / slice contract
- Latest STATE.md / receipt / gate-results.json
- Project AGENTS.md / local governance
- External memory or generated maps (Obsidian, Graphify) if configured
- Agent judgment (must be labeled JUDGMENT)
Project-local governance always overrides these global fallback rules.
Optional Buildloop Runtime Tools
Use these only when they exist in the current repo. Do not invent them, install Docker, or assume they are available.
| Tool | When To Use | Boundary |
|---|---|---|
node scripts/detect-capabilities.mjs |
Read-only capability scan during Step 0 / Step 1A | Writes only with explicit --write |
node scripts/buildloop.mjs doctor |
Human-readable repo readiness report | Supervised/read-only |
node scripts/buildloop.mjs gates |
Run .buildloop.yml gates |
Uses project-defined commands |
node scripts/buildloop.mjs review |
Review latest gate-results.json |
Reads evidence; does not self-grade |
node scripts/sandbox-run.mjs --dry-run |
Inspect Docker sandbox plan for untrusted commands | Dry-run by default |
node scripts/sandbox-run.mjs --execute |
Run a sandboxed command only after explicit approval | Docker required; no secrets; offline network default |
Obsidian and Graphify context is advisory-only. Read only explicit configured paths, respect token budgets, never auto-promote lessons, and never write bridge output unless a future approved phase explicitly changes that contract.
L4/overnight autonomy is not enabled by this skill. Any L4+ action requires a separate threat model, explicit human approval, and verified sandbox evidence.
Step 0: Classify and Select Profile
Before anything else, classify the project:
| Signal | Classification |
|---|---|
| Empty or near-empty directory | GREENFIELD |
| Existing files + git history, no governance | BROWNFIELD |
| Existing files + AGENTS.md + receipts + state | GOVERNED |
| Governance exists but conflicts with repo reality | STALE_OR_MIXED |
| User asks for analysis, not code changes | REVIEW_ONLY |
| User asks to ship, deploy, or prepare release | RELEASE |
| Steps 0–8 already approved, looping on stories | AUTONOMOUS_LOOP |
If Buildloop runtime tools are present, prefer buildloop doctor or detect-capabilities.mjs as supporting evidence for classification. If they are absent, continue with normal repo inspection.
GREENFIELD Path
Steps: 0 → 1A → 2 → 3 → 4 → 7 → 8 → 9 → 11 → 14
Rule: Build first, govern after proof. Do NOT front-load ceremony.
- Step 1A — Minimal audit:
git status, branch, runtime, package manager, existing files. - Step 2 — PRD: Clarify outcome. Ask only questions that affect architecture, risk, or UX.
- Step 3 — Adversarial Spec: Apply grill-me to the PRD. Risk-scaled probe count (see below).
- Step 4 — Architecture Checkpoint: Simplest version that works. Karpathy check: "Would a senior engineer say this is overcomplicated?"
- Step 7 — Slice Contract: Define
allowed_files,blast_radius,evidence_required. - Step 8 — Human Approval (Planning Gate): Present DECISION REQUIRED block. Wait for approval.
- Steps 9–11 — Build, self-review, deterministic gates.
- Step 14 — PR / Preview.
BROWNFIELD Path
Steps: 0 → 1A → 1B → [STABILIZE if needed] → 2 → full lifecycle
Rule: Never build on a broken foundation. Diagnose before building.
Step 1A — Minimal Audit (all brownfield)
git status, branch, file count, package manager, runtime- Check for:
AGENTS.md,CLAUDE.md,.cursorrules, CI config, existing skills
Step 1B — Full Diagnostic
Run the repo's native checks:
lint / typecheck / test / build
Produce diagnostic_baseline.md with frontmatter:
---
type: diagnostic_baseline
repo_state: B | C | D
health:
build: PASS | FAIL | NOT_CONFIGURED
tests: PASS | FAIL | NONE
lint: PASS | FAIL | NOT_CONFIGURED
ci: CONFIGURED | NONE
stabilization_required: true | false
---
Stabilization Gate
If stabilization_required: true:
- Present stabilization plan (minimum changes to unblock features)
- BLOCK feature work until human approves and foundation is verified
- If repo healthy → generate
.buildloop.yml→ proceed to Step 2
Brownfield Non-Negotiables
| Existing | Do | Never |
|---|---|---|
| AGENTS.md | Read. Suggest improvements. | Overwrite. |
| CLAUDE.md | Add skill routing only if missing. | Replace. |
| CI / Makefile | Respect it. .buildloop.yml adapts. | Replace. |
| Task tracker | Use existing (Issues/Jira). | Force prd.json. |
| Skills | Deduplicate. Skip overlap. | Install duplicates. |
| Test framework | Run existing. | Replace framework. |
AUTONOMOUS Path
Prerequisite: Steps 0–8 must be fully approved before this path runs.
Loop: 9 (TDD) → 10 (self-review) → 11 (gates) → 12 (AI review) → receipt → commit → next approved slice
Autonomous mode reads .buildloop.yml for commands and protected_paths. If stuck (3+ consecutive failures): emit STUCK signal, escalate to human.
Autonomous loop is still supervised slice execution. It is not L4 overnight autonomy and must not run deploy, auto-fix, credential, migration, or production actions without explicit human approval.
Risk-Scaled Grill-Me Probes
Apply when stress-testing PRD, architecture, or slice contract:
| Risk Level | Probe Count |
|---|---|
| Low (cosmetic / additive) | 1–2 probes |
| Medium (new feature, integration) | 3 probes |
| High (auth, schema, billing, external API) | 5–7 probes |
Never exceed 7 probes unless human asks. Each probe: Q + recommended A. Human approves/modifies/rejects.
Gate Format (Required at Every Human Checkpoint)
DECISION REQUIRED
Recommendation: PROCEED / FIX / HALT
Why: [1–2 sentences, plain language]
Risk: LOW / MEDIUM / HIGH
What I need from you: approve / modify / reject
If approved, next action: [explicit next step]
Deterministic Gates (Step 11)
Gate-runner reads .buildloop.yml:
adoption_mode: greenfield | brownfield | autonomous
risk_level: low | medium | high
commands:
lint: "[your lint command]"
typecheck: "[your typecheck command]"
test: "[your test command]"
build: "[your build command]"
protected_paths:
- ".env*"
- "**/*.key"
- ".github/workflows/**"
Gate-runner produces gate-results.json. Evidence receipt references it. Gate-runner is the independent witness — the agent does not self-grade.
If scripts/buildloop.mjs is present, use node scripts/buildloop.mjs gates and node scripts/buildloop.mjs review as the preferred supervised wrapper. If it is absent, run the repo's native checks directly and label any missing gate witness as UNVERIFIED.
Delegation Rule
The orchestrator routes work to specialists. It does not pretend to be every skill.
| Need | Delegate To |
|---|---|
| TDD execution | tdd, writing-plans, executing-plans |
| Architecture refactor | improve-codebase-architecture, zoom-out |
| UI / design | awesome-design-md |
| Plan stress-test | grill-me |
| Requirements / PRD | grill-with-docs, to-prd, brainstorming |
| Token compression | caveman |
| Anti-overcomplication | karpathy-guidelines |
| Debugging | diagnose |
| Code review / release | requesting-code-review, verification-before-completion, finishing-a-development-branch |
| Security | security-best-practices, security-threat-model |
| Issue triage | triage |
Read reference/quality-gates.md and reference/security-triggers.md for risk-level controls.
Quality Gates (Do Not Ship Without These)
- Acceptance criteria mapped to concrete verification
- Tests cover changed behavior + at least one failure path
- Security-sensitive flows: auth, authorization, validation considered
- Data changes: migration and rollback path verified
- No unrelated drive-by changes in the diff
-
gate-results.jsonexists and shows PASS
Self-Review Checklist
Before claiming any task complete, answer:
- Did I stay inside allowed files?
- Did I verify each acceptance criterion?
- What remains UNVERIFIED?
- What changed outside planned scope?
- What test/check would fail if I am wrong?
- What rollback exists?
Output Contract
Planning output:
- Assumptions
- Repo Truth / Known Facts
- Recommended Profile
- Plan
- Risks
- Human Decision Needed
- Next Action
Execution output:
- Slice Contract
- Implementation Summary
- Gate Results
- Evidence Receipt
- Review Findings
- Remaining Risks
- Human Decision Needed
Stop Conditions
Pause and ask before:
- Deleting data, force-pushing, rotating production credentials
- Touching
protected_pathsfrom.buildloop.yml - Making irreversible architecture choices when requirement is unclear
- Proceeding when tests cannot run and change is high-risk
- Taking any action at L4+ autonomy level without explicit opt-in
- Running
sandbox-run --execute, full network mode, deploys, migrations, or production-impacting commands without explicit human approval - About to guess architecture instead of inspecting repo truth
- Gate/test/build failure persists after 3 fix attempts — halt and report