Skip to main content
ClaudeWave
Slash Command125 repo starsupdated 1mo ago

claudikins-kernel:execute

Execute validated plans with isolated agents and two-stage review

Install in Claude Code
Copy
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/elb-pr/claudikins-kernel/HEAD/commands/execute.md -o ~/.claude/commands/claudikins-kernel-execute.md
Then start a new Claude Code session; the slash command loads automatically.

execute.md

# claudikins-kernel:execute Command

You are orchestrating a task execution workflow with isolated agents and human checkpoints between batches.

## Flags

| Flag            | Effect                                              |
| --------------- | --------------------------------------------------- |
| `--resume`      | Resume from last checkpoint                         |
| `--status`      | Show current execution status                       |
| `--abort`       | Abort current execution (saves checkpoint)          |
| `--batch N`     | Override batch size (default: from plan)            |
| `--model M`     | Model for agents: `opus` or `sonnet` (default: opus)|
| `--skip-review` | Skip code review (spec review still runs)           |
| `--dry-run`     | Parse plan and show execution order without running |
| `--timing`      | Show task and batch durations                       |
| `--trace`       | Show execution trace at completion                  |

## Merge Strategy

None - task outputs are saved per-task, not merged.

## Philosophy

> "5-7 agents per SESSION, not 30 per batch. Features are the unit of work." - Boris

- One task = one branch (isolation prevents pollution)
- Fresh context per task (context: fork)
- Two-stage review (spec compliance, then code quality)
- Human checkpoints between batches (not individual tasks)
- Commands own git (agents never checkout/merge/push)

## Load Skill

First, load the git-workflow skill for methodology:

```
Skill(git-workflow)
```

This provides:

- Task decomposition patterns
- Review criteria and thresholds
- Batch checkpoint decision trees
- Circuit breaker and tracing patterns

## State Management

State file: `.claude/execute-state.json`

```json
{
  "session_id": "exec-YYYY-MM-DD-HHMM",
  "plan_source": "path/to/plan.md",
  "started_at": "ISO timestamp",
  "status": "initialising|executing|paused|completed|aborted",
  "current_batch": 1,
  "current_task": null,
  "tasks": [...],
  "batches": [...],
  "last_checkpoint": null
}
```

## Phase 0: Initialisation

### Flag Handling

Check for flags first:

```
--status → Run execute-status.sh hook, display status, exit
--resume → Load checkpoint, resume from saved state
--abort → Save checkpoint, mark aborted, exit
--dry-run → Parse and display, don't execute
--model → Set agent model (opus|sonnet), stored in execute-state.json
```

### Model Selection

If `--model` flag is provided, use the specified model. Otherwise, prompt the user:

```
AskUserQuestion({
  question: "Which model should agents use for this execution?",
  header: "Model Selection",
  options: [
    { label: "Opus", description: "Most capable — best for complex tasks (uses more session quota)" },
    { label: "Sonnet", description: "Fast and capable — good for straightforward tasks (lighter on quota)" }
  ]
})
```

Store the selected model in `execute-state.json` as `"model": "opus"|"sonnet"`. All `Task()` calls for babyclaude, spec-reviewer, and code-reviewer must use this value.

### Plan Loading

1. Get plan path from argument or find most recent in `.claude/plans/`
2. Validate EXECUTION_TASKS markers exist (hook: validate-plan-format.sh)
3. Parse task table between markers
4. Build dependency graph

**On validation failure:**

```
Plan missing EXECUTION_TASKS markers.

The plan must include:
  <!-- EXECUTION_TASKS_START -->
  | # | Task | Files | Deps | Batch |
  ...
  <!-- EXECUTION_TASKS_END -->

Run claudikins-kernel:outline to generate a properly formatted plan.
```

### Dependency Graph

Build from parsed table:

```json
{
  "tasks": [
    {
      "id": "1",
      "name": "Create schema",
      "files": ["prisma/schema.prisma"],
      "deps": [],
      "batch": 1
    },
    {
      "id": "2",
      "name": "Add service",
      "files": ["src/services/user.ts"],
      "deps": ["1"],
      "batch": 1
    },
    {
      "id": "3",
      "name": "Create routes",
      "files": ["src/routes/user.ts"],
      "deps": ["2"],
      "batch": 2
    }
  ],
  "batches": [
    { "id": 1, "tasks": ["1", "2"], "status": "pending" },
    { "id": 2, "tasks": ["3"], "status": "pending" }
  ]
}
```

### Pre-Execution Validation

Per batch-size-verification.md:

```
if tasks.length > 15:
  WARN "Large execution (${tasks.length} tasks). Consider splitting."
  [Continue] [Abort]

if any_batch.tasks.length > 7:
  WARN "Batch ${batch.id} exceeds 7 tasks. Review batch boundaries."
  [Continue] [Adjust batches] [Abort]
```

### LOC Estimation

Per review-criteria.md (400 LOC threshold):

```
Estimate task LOC from file list.
If estimated > 400 LOC:
  WARN "Task ${task.id} may exceed review threshold (~${estimate} LOC)"
  [Proceed] [Split task] [Accept with caveat]
```

### Context Budget Validation

Per babyclaude's context budget guidelines:

| Resource        | Soft Limit | Hard Limit | Pre-Execution Action |
| --------------- | ---------- | ---------- | -------------------- |
| Files to modify | 5          | 10         | Warn if exceeded     |
| Lines of code   | 200        | 400        | Suggest split        |
| Dependencies    | 3          | 5          | Check batch ordering |

```
Task ${task.id} context budget check:
  Files: ${files.length} (limit: 5-10)
  Est. LOC: ~${estimate} (limit: 200-400)

  ${files.length > 5 ? "WARN: Task touches many files" : "OK"}
  ${estimate > 200 ? "WARN: Large task - monitor context usage" : "OK"}
```

If both limits exceeded, strongly recommend splitting before execution.

## Phase 1: Batch Start Checkpoint

For each batch:

```
Batch ${batch.id}/${total_batches}: Ready to execute

Tasks in this batch:
| # | Task | Files | Deps |
|---|------|-------|------|
| 1 | Create schema | prisma/schema.prisma | - |
| 2 | Add service | src/services/user.ts | 1 |

[Execute batch] [Skip task X] [Reorder] [Pause] [Abort]
```

## Phase 2: Task Execution

For each task in batch:

### 2.1 Branch Creation (via create-task-branch.sh hook)

```
Creating branch: execute/task-${id}-${slug}-${uuid}
```

The hook:

1. V