Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .claude/skills/mission-plan/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: mission-plan
description: Turn an open-ended objective into a structured Missions plan (milestones + features + dependencies + path ownership) for the Contexture orchestrator. Use when the user wants to plan a multi-feature mission and have agents execute it.
---

You are turning a free-form objective into a structured `MissionPlan` that the orchestrator can execute. You will:

1. **Grill the user** until the objective is unambiguous and properly scoped.
2. **Emit a JSON plan** matching the schema in [`schema-reference.md`](schema-reference.md).

Do not skip step 1. A bad plan compounds — every feature in a mission is acted on by an autonomous agent. Five minutes of clarifying questions saves hours of wasted runs.

## Step 1: Grill until unambiguous

Ask, in order, whatever you don't already know from context:

- **What outcome does this mission deliver?** Push for a single sentence.
- **What's done at the end?** Concrete acceptance criteria (e.g. "Convex schema emit works for the existing IR test fixtures and `bun run ci` is clean").
- **Where does the work live?** Specific paths or globs (e.g. `packages/core/src/emit-convex/**`). This drives `pathsOwned` and lets the scheduler parallelise safely.
- **What's the natural ordering?** Identify dependencies between sub-tasks. If two features can be done in parallel, say so explicitly.
- **What's the right milestone boundary?** A milestone is a checkpoint where the integrated state must pass `bun run ci` and a validator agent's success criteria. Don't put unrelated work in the same milestone.
- **Which agent should do what?** Default `claude` for most coding work. Use `codex` if the user has a preference for a specific feature.
- **Skill references** — does any feature need particular knowledge (e.g. `frontend`, `backend`, `db`, `tests`)? Available skills are in `.sandcastle/missions/skills/`.

Stop asking when you can write a plan that:

- Has at least one milestone.
- Each milestone has at least one feature.
- Every feature has a non-trivial prompt that an agent could act on autonomously, owned paths, and explicit dependencies.
- Success criteria are testable (`bun run ci` clean, specific commands pass, explicit assertions).

If the user pushes back on a question, take their answer and move on. Don't loop.

## Step 2: Emit the plan

Output the plan as a single JSON code block fenced with ` ```json `. Match the schema in [`schema-reference.md`](schema-reference.md) exactly — the orchestrator validates it with Zod and rejects anything malformed.

After the code block, add a one-paragraph summary of what you've planned, why you grouped features into milestones the way you did, and any assumptions you made.

If the user invoked you headlessly via `bun run mission plan "<objective>"`, the orchestrator will capture the JSON code block, validate it, and insert the mission into Convex. Do not write any files yourself.

If the user invoked you interactively (`/mission-plan`), the user will save the JSON to a file and then run `bun run mission plan --apply <path>` to ingest it.

## Conventions

- `slug` fields: lowercase letters, digits, hyphens. Used in branch names (`mission/<missionSlug>/<featureSlug>`).
- `pathsOwned`: glob patterns. Used for path-conflict detection — features whose owned paths overlap will be serialised, not run in parallel. Be precise: `packages/core/**` is too broad if only `packages/core/src/emit-convex/**` is touched.
- `dependencies`: feature slugs (within the same mission) that must finish before this one starts.
- `successCriteria`: concrete, testable statements. The validator agent at the milestone gate evaluates these.
- `validationPrompt`: instructions to the validator agent — what to run, what to look at, what counts as pass/fail.
80 changes: 80 additions & 0 deletions .claude/skills/mission-plan/schema-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# MissionPlan JSON schema

The orchestrator validates emitted plans against [`.sandcastle/missions/schema.ts`](../../../.sandcastle/missions/schema.ts) (Zod). This document is the human-readable mirror — keep them in sync.

## Top-level shape

```json
{
"slug": "convex-ir-2026-05",
"title": "Bring up Convex emit for the IR",
"objective": "Generate Convex schemas, mutations, and CRUD seeds from the existing IR fixtures.",
"milestones": [ /* at least one */ ]
}
```

| Field | Type | Notes |
|---|---|---|
| `slug` | string | lowercase letters, digits, hyphens; unique across all missions |
| `title` | string | human-readable |
| `objective` | string | one or two sentences |
| `milestones` | array | at least one milestone |

## Milestone

```json
{
"slug": "schema-emit",
"title": "Schema emit",
"successCriteria": [
"Convex schema.ts is emitted for every IR table",
"bun run typecheck passes in apps/missions"
],
"validationPrompt": "Run bun run ci. Inspect packages/schema/convex/schema.ts and confirm every table from the IR is present.",
"features": [ /* at least one */ ]
}
```

| Field | Type | Notes |
|---|---|---|
| `slug` | string | unique within the mission |
| `title` | string | human-readable |
| `successCriteria` | array of strings | at least one; concrete and testable |
| `validationPrompt` | string | what the validator agent runs at the milestone gate |
| `features` | array | at least one |

## Feature

```json
{
"slug": "emit-schema-ts",
"title": "Emit schema.ts from IR",
"prompt": "Add an emitter function in packages/core/src/emit-convex/schema.ts that walks the IR and produces convex/schema.ts. Use existing IR types from packages/core/src/ir.ts.",
"dependencies": [],
"pathsOwned": ["packages/core/src/emit-convex/**"],
"preferredAgent": "claude",
"skillRefs": ["backend"]
}
```

| Field | Type | Notes |
|---|---|---|
| `slug` | string | unique across all features in the mission |
| `title` | string | human-readable |
| `prompt` | string | the instruction the worker agent receives. Be specific. |
| `dependencies` | array of feature slugs | features that must finish before this starts. Defaults to `[]`. |
| `pathsOwned` | array of globs | files/dirs this feature is allowed to modify. Used for conflict detection. Defaults to `[]`. |
| `preferredAgent` | "claude" \| "codex" | defaults to "claude" |
| `skillRefs` | array of strings | references to `.sandcastle/missions/skills/<name>.md`. Defaults to `[]`. |

## Validation

The orchestrator rejects plans where:

- A `slug` doesn't match `/^[a-z0-9][a-z0-9-]*$/`.
- A milestone has zero features, or a mission has zero milestones.
- A feature's `dependencies` reference an unknown feature slug.
- Two features share the same slug.
- Required string fields are empty.

When validation fails, the orchestrator re-prompts you with the validation error. Read it carefully and emit a corrected plan. Do not start over from scratch.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ playwright-report/

# Sensitive docs migrated to Paperclip issue documents (ONT-49)
Marketing/

# Local mission plan files for smoke testing / experiments
smoke-*-plan.json
mission-plan-*.json

16 changes: 13 additions & 3 deletions .sandcastle/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Anthropic API key
# If you want to use your Claude subscription instead of an API key, see https://github.com/mattpocock/sandcastle/issues/191
# Anthropic API key (only needed if not running the planner via Claude Code).
# The planner uses your Claude subscription via the `claude` CLI; workers use it
# inside Sandcastle containers (slice 2+).
ANTHROPIC_API_KEY=
# GitHub personal access token

# GitHub personal access token used for `gh pr create` from the orchestrator.
GH_TOKEN=

# Convex deployment URL. For local dev, copy from apps/missions/.env.local
# (CONVEX_URL line) after running `bun run convex:dev`.
CONVEX_URL=

# Optional: Convex deploy/admin key. Required when talking to a cloud
# deployment; not needed for local dev.
CONVEX_DEPLOY_KEY=
113 changes: 0 additions & 113 deletions .sandcastle/eligibility.test.ts

This file was deleted.

72 changes: 0 additions & 72 deletions .sandcastle/eligibility.ts

This file was deleted.

Loading
Loading