| name | lev-builder |
| description | lev POC-to-core builder with prior art, placement, patches, and E2E validation. Use when formalizing POCs, migrating workshop code, or choosing canonical paths under lev docs. |
| 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/domain or a new plugin?" │
│ ├─ Consult paths reference above + architecture primer │
│ └─ 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
For current architecture, see ~/.agents/skills/lev/references/architecture-primer.md
~/lev/core/
├── build/
├── config/
├── daemon/
├── domain/
├── event-bus/
├── event-machines/
├── event-providers/
├── exec/
├── flowmind/
├── graph/
├── harness/
├── index/
├── logger/
├── memory/
├── orchestration/
├── plugin-manager/
Quick Commands
1. Assess Topic
lev get "topic" --indexes codebase,docs,skills,tasks
ls ~/lev/core/ | grep -i <topic>
ls ~/lev/plugins/ | grep -i <topic>
ls ~/lev/workshop/poc/ | grep -i <topic>
ls ~/.agents/skills/ | grep -i <topic>
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/domain or plugins/guardrails?",
options: [
{ path: "core/domain/fleet-rbac.ts", reason: "Core domain logic" },
{ path: "plugins/guardrails/fleet-rbac.ts", reason: "Safety/access is a plugin concern" }
],
context: "Fleet auth controls who can spawn agents and access data"
})
4. Graph Plan + File Patch
cat pm/designs/<feature>.md | \
./scripts/design-to-patch.sh > patches/<feature>.patch
./scripts/apply-patch.sh patches/<feature>.patch --dry-run
./scripts/apply-patch.sh patches/<feature>.patch --target ~/lev/core/<module>/
5. Validate E2E
cd ~/lev && bun run typecheck
bun test core/<module>/
bun test:integration --filter "<feature>"
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 |
cdo | Graph operations - state machines |
Common Workflows
Workflow 1: New Feature
USER: "Add event-driven scheduling to Leviathan"
BUILDER:
1. ASSESS: lev get "scheduling\|event\|cron"
→ Found: core/event-machines has state machines, core/orchestration exists
2. PRIOR ART: bd search "scheduling"
→ Found: core-scheduling plugin exists in plugins/
3. PLACEMENT: Escalate "core/orchestration vs plugins/core-scheduling?"
→ User: "core/orchestration — it's a core concern"
4. PATCH: Generate scheduler.ts from design doc
→ Created: ~/lev/core/orchestration/scheduler.ts
5. VALIDATE: bun run typecheck && bun test core/orchestration/
→ 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/exec" or "plugins/" (depends on scope)
→ Confirmed
4. PATCH: Copy + adapt for lev structure
→ Created: ~/lev/core/exec/builder/ (or plugins/builder/)
5. VALIDATE: bun test core/exec/
→ Passed
6. MIGRATE: git commit, update registry
→ Done
Workflow 3: Assess & Consolidate
USER: "What exists for memory persistence in Leviathan?"
BUILDER:
1. ASSESS:
lev get "memory\|persistence\|storage" --indexes codebase,docs
→ Found:
- core/memory/ (memory layer)
- core/storage/ (storage abstractions)
- plugins/evolve-memory/ (memory evolution plugin)
2. REPORT:
"Memory/persistence exists in 3 places:
- core/memory: production memory layer
- core/storage: storage abstractions
- plugins/evolve-memory: evolution/migration plugin
Recommend: Verify boundaries are clean, consolidate if overlapping"
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/domain" },
{ text: "Option B", callback_data: "placement:plugins/guardrails" },
{ text: "Discuss", callback_data: "placement:discuss" },
]
});
State Tracking
# .lev/builder/state.jsonl
{"ts":"...","action":"assess","topic":"scheduling","results":["core/orchestration","plugins/core-scheduling"]}
{"ts":"...","action":"prior_art","topic":"scheduling","found":true,"matches":1}
{"ts":"...","action":"escalate","type":"PLACEMENT_DECISION","resolved":true,"choice":"core/orchestration"}
{"ts":"...","action":"patch","target":"core/orchestration/scheduler.ts","status":"created"}
{"ts":"...","action":"validate","target":"core/orchestration/","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.