| name | lev-builder |
| description | [WHAT] Builder workflow for developing `~/lev` and migrating proven work to core paths.
[HOW] Assess existing code, run prior art checks, decide placement against `~/lev/docs`, apply patches, validate E2E.
[WHEN] Use when formalizing POCs, placing modules, or migrating workshop output into production architecture.
[WHY] Prevents drift and duplicate effort by enforcing file-based routing and docs-aligned placement.
Triggers: "build feature", "migrate poc", "where should this go", "prior art check", "placement decision", "formalize"
|
| skill_type | workflow |
| category | process-builder |
| lifecycle_integration | {"stage":"manifesting","input_artifact":"design doc + POC code","output_artifact":"production code in lev/core"} |
lev-builder: POC → Formalize → Migrate
Core principle: Build in a workspace POC, prove it works, migrate to ~/lev canonical paths.
Why This Exists
PROBLEM:
- Work happens across mixed workspaces (project-local, workshop, plugins)
- BD issues are in lev (lev-* prefix)
- Need to know WHERE to put things in Leviathan
- Need prior art check before creating new
SOLUTION:
- lev-builder orchestrates the full workflow
- POC in `~/lev/workshop/poc` (or project-local skills) → migrate to `~/lev/core` when proven
- Uses graph operations for decisioning, then applies explicit filesystem patches during migration
The Builder Workflow
┌─────────────────────────────────────────────────────────────────┐
│ LEV-BUILDER WORKFLOW │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 1️⃣ ASSESS (What exists?) │
│ ├─ lev get "topic" --indexes codebase,docs,skills │
│ ├─ Check ~/lev/core/* for existing modules │
│ ├─ Check ~/lev/workshop/poc/* for prior POCs │
│ └─ Output: Related code, docs, skills found │
│ │
│ 2️⃣ PRIOR ART CHECK (Duplicate prevention) │
│ ├─ ./scripts/prior-art-check.sh "topic" │
│ ├─ bd search "topic" │
│ ├─ Skill lookup: ~/lev/workshop/poc/lookup/ │
│ └─ Output: Existing work to patch vs. new work to create │
│ │
│ 3️⃣ PLACEMENT DECISION (Where does it go?) │
│ ├─ Escalate to user if ambiguous │
│ │ "Should this be in core/auth or core/vault?" │
│ ├─ Consult LEVIATHAN_PATHS.md │
│ └─ Output: Target path confirmed │
│ │
│ 4️⃣ GRAPH PLAN + FILE PATCH │
│ ├─ Generate graph mutation plan from design doc │
│ ├─ Materialize approved changes as filesystem patch │
│ ├─ Apply to target location │
│ └─ Output: Files created/modified │
│ │
│ 5️⃣ E2E VALIDATION (Confirm it works) │
│ ├─ Run relevant tests │
│ ├─ Typecheck: bun run typecheck │
│ ├─ Integration test if applicable │
│ └─ Output: Validation results │
│ │
│ 6️⃣ MIGRATE (POC → Production) │
│ ├─ If POC in workshop/project skills: move to lev/core │
│ ├─ Update skill registry │
│ ├─ Create migration PR/commit │
│ └─ Output: Migration complete │
│ │
└─────────────────────────────────────────────────────────────────┘
Leviathan Paths Reference
~/lev/core/
├── harness/
├── auth/
├── cdo/
├── commands/
├── config/
├── daemons/
├── graph/
├── lifecycle/
├── memory/
├── vault/
└── ...
~/lev/workshop/
├── intake/
├── poc/
│ └── lookup/
└── ...
Quick Commands
1. Assess Topic
lev get "fleet authorization" --indexes codebase,docs,skills,tasks
ls ~/lev/core/ | grep -i auth
ls ~/lev/workshop/poc/ | grep -i auth
ls ~/.agents/skills/ | grep -i auth
2. Prior Art Check
./scripts/prior-art-check.sh "data vault leases"
bd search "vault" --root-path ~/lev
bd search "lease" --root-path ~/lev
node ~/lev/workshop/poc/lookup/cli.js search "authorization"
3. Escalate Decision
escalate({
type: "PLACEMENT_DECISION",
question: "Should fleet-rbac.ts go in core/auth or core/permissions?",
options: [
{ path: "core/auth/fleet-rbac.ts", reason: "Auth is about identity" },
{ path: "core/permissions/fleet-rbac.ts", reason: "RBAC is permissions" }
],
context: "Fleet auth controls who can spawn agents and access data"
})
4. Graph Plan + File Patch
cat pm/designs/fleet-swarm-authorization.md | \
./scripts/design-to-patch.sh > patches/fleet-auth.patch
./scripts/apply-patch.sh patches/fleet-auth.patch --dry-run
./scripts/apply-patch.sh patches/fleet-auth.patch --target ~/lev/core/auth/
5. Validate E2E
cd ~/lev && bun run typecheck
bun test core/auth/
bun test:integration --filter "fleet"
6. Migrate POC
./scripts/migrate-skill.sh ~/lev/workshop/poc/lev-builder ~/lev/core/builder
./scripts/update-skill-registry.sh
cd ~/lev && git add . && git commit -m "feat: migrate lev-builder from POC"
Integration with Other Skills
| Skill | Role in Builder |
|---|
lev get | Assessment - search across indexes |
lev-patch | Prior art - check before creating |
planning | Spec authoring backend - CDO graph to execution |
ralph | Execution - run tasks with validation |
lev-cdo | Graph operations - state machines |
Common Workflows
Workflow 1: New Feature
USER: "Add fleet authorization to Leviathan"
BUILDER:
1. ASSESS: lev get "fleet\|authorization\|rbac"
→ Found: core/config has some auth, no fleet module
2. PRIOR ART: bd search "authorization"
→ Found: lev-qtpq.7 task exists for this
3. PLACEMENT: Escalate "core/auth vs core/permissions?"
→ User: "core/auth"
4. PATCH: Generate fleet-rbac.ts from design doc
→ Created: ~/lev/core/auth/fleet-rbac.ts
5. VALIDATE: bun run typecheck && bun test core/auth/
→ Passed
6. MIGRATE: N/A (already in lev/core)
Workflow 2: POC to Production
USER: "Migrate lev-builder skill to production"
BUILDER:
1. ASSESS: ls ~/lev/workshop/poc/lev-builder/
→ Found: SKILL.md, scripts/
2. PRIOR ART: ls ~/lev/core/builder/
→ Not found (new module)
3. PLACEMENT: "core/builder" (builder is core infra)
→ Confirmed
4. PATCH: Copy + adapt for lev structure
→ Created: ~/lev/core/builder/
5. VALIDATE: bun test core/builder/
→ Passed
6. MIGRATE: git commit, update registry
→ Done
Workflow 3: Assess & Consolidate
USER: "What exists for caching in Leviathan?"
BUILDER:
1. ASSESS:
lev get "cache\|caching" --indexes codebase,docs
→ Found:
- core/config/cache.ts (config caching)
- workshop/poc/redis-cache/ (POC)
- docs/decisions/ADR-045-caching.md (decision)
2. REPORT:
"Caching exists in 3 places:
- Config cache: production (core/config)
- Redis POC: not migrated (workshop/poc)
- ADR-045: recommends unified cache layer
Recommend: Consolidate into core/cache/"
3. ESCALATE: "Proceed with consolidation?"
Escalation Patterns
const ESCALATION_TRIGGERS = [
"PLACEMENT_DECISION",
"CONSOLIDATION_DECISION",
"ARCHITECTURE_DECISION",
"MIGRATION_APPROVAL",
"DEPENDENCY_ADDITION",
];
await escalate({
type: "PLACEMENT_DECISION",
question: "...",
options: [...],
buttons: [
{ text: "Option A", callback_data: "placement:core/auth" },
{ text: "Option B", callback_data: "placement:core/permissions" },
{ text: "Discuss", callback_data: "placement:discuss" },
]
});
State Tracking
# .lev/builder/state.jsonl
{"ts":"...","action":"assess","topic":"fleet auth","results":["core/auth","lev-qtpq.7"]}
{"ts":"...","action":"prior_art","topic":"fleet auth","found":true,"matches":1}
{"ts":"...","action":"escalate","type":"PLACEMENT_DECISION","resolved":true,"choice":"core/auth"}
{"ts":"...","action":"patch","target":"core/auth/fleet-rbac.ts","status":"created"}
{"ts":"...","action":"validate","target":"core/auth/","passed":true}
Summary
lev-builder answers:
- What exists? → Assess with lev get
- Is there prior art? → Check with lev-patch
- Where does it go? → Escalate placement decisions
- How to apply? → Graph plan + explicit filesystem patch
- Does it work? → E2E validation
- Ready for production? → Migrate POC to lev/core
Relates
Master Router
- Lev Master Router (
lev/SKILL.md) - Routes all lev-* skills
Parent skill that dispatches to this skill based on keywords/context
Technique Map
- Role definition - Clarifies operating scope and prevents ambiguous execution.
- Context enrichment - Captures required inputs before actions.
- Output structuring - Standardizes deliverables for consistent reuse.
- Step-by-step workflow - Reduces errors by making execution order explicit.
- Edge-case handling - Documents safe fallbacks when assumptions fail.
Technique Notes
These techniques improve reliability by making intent, inputs, outputs, and fallback paths explicit. Keep this section concise and additive so existing domain guidance remains primary.
Prompt Architect Overlay
Role Definition
You are the prompt-architect-enhanced specialist for lev-builder, responsible for deterministic execution of this skill's guidance while preserving existing workflow and constraints.
Input Contract
- Required: clear user intent and relevant context for this skill.
- Preferred: repository/project constraints, existing artifacts, and success criteria.
- If context is missing, ask focused questions before proceeding.
Output Contract
- Provide structured, actionable outputs aligned to this skill's existing format.
- Include assumptions and next steps when appropriate.
- Preserve compatibility with existing sections and related skills.
Edge Cases & Fallbacks
- If prerequisites are missing, provide a minimal safe path and request missing inputs.
- If scope is ambiguous, narrow to the highest-confidence sub-task.
- If a requested action conflicts with existing constraints, explain and offer compliant alternatives.