--- description: Execute the implementation planning workflow for superset-tools (Python backend + Svelte frontend) and generate research, design, contracts, and quickstart artifacts. handoffs: - label: Create Tasks agent: speckit.tasks prompt: Break the plan into executable tasks for Python/Svelte implementation send: true - label: Create Checklist agent: speckit.checklist prompt: Create a requirements-quality checklist for the active feature --- ## User Input ```text $ARGUMENTS ``` You **MUST** consider the user input before proceeding (if not empty). ## Outline 1. **Setup**: Run `.specify/scripts/bash/setup-plan.sh --json` from repo root and parse `FEATURE_SPEC`, `IMPL_PLAN`, `SPECS_DIR`, and `BRANCH`. - `IMPL_PLAN` is the authoritative path for `plan.md` inside `specs//`. - Derive `FEATURE_DIR` from `IMPL_PLAN` and write every planning artifact there. - Never treat `.kilo/plans/*` as workflow output for `/speckit.plan`. 2. **Load canonical planning context**: - `README.md` - `requirements.txt` (backend dependencies) - `frontend/package.json` (frontend dependencies) - `.specify/memory/constitution.md` - `.opencode/skills/semantics-core/SKILL.md` - `.opencode/skills/semantics-contracts/SKILL.md` - `.opencode/skills/semantics-python/SKILL.md` - `.opencode/skills/semantics-svelte/SKILL.md` - `.opencode/skills/semantics-testing/SKILL.md` - `.specify/templates/plan-template.md` - `FEATURE_DIR/contracts/ux/screen-models.md` (if `/speckit.ux` was run) - `FEATURE_DIR/contracts/ux/api-ux.md` (if `/speckit.ux` was run) - `FEATURE_DIR/contracts/ux/*-ux.md` (per-screen UX contracts) - relevant `docs/adr/*.md` 3. **Execute the planning workflow** using the template structure: - Fill `Technical Context` for the current repository reality: Python 3.9+/FastAPI backend, SvelteKit 5/Tailwind frontend, PostgreSQL, Docker, semantic contracts, belief runtime. - Fill `Constitution Check` using the local constitution. - ERROR if a blocking constitutional or semantic conflict is discovered and cannot be justified. - Phase 0: generate `research.md` in `FEATURE_DIR`, resolving all material unknowns. - Phase 1: generate `data-model.md`, `contracts/modules.md`, optional machine-readable contract artifacts, and `quickstart.md` in `FEATURE_DIR`. - Phase 1: if UX contracts exist, generate `traceability.md` — a requirements traceability matrix mapping Story → Model → API → Task → Test. - Materialize blocking ADR references and planning decisions inside the plan and downstream contracts. - Run `.specify/scripts/bash/update-agent-context.sh kilocode` after planning artifacts are written. 4. **Stop and report** after planning artifacts are complete. Report branch, `plan.md` path, generated artifacts, and blocking ADR/decision-memory outcomes. ## Phase 0: Research Research must resolve only implementation-shaping unknowns that matter for this repository, such as: - module placement under `backend/src/` or `frontend/src/` - **Screen Model topology**: which screens need a `[TYPE Model]` (`.svelte.ts`), which atoms each model declares, which invariants cross widget boundaries - API endpoint design (REST routes, WebSocket channels) - database schema changes (SQLAlchemy models, migrations) - Svelte component hierarchy and store topology - async task orchestration patterns - **TypeScript DTO alignment**: frontend `types/` matching backend Pydantic schemas - test strategy (pytest + vitest; L1 model invariants without render + L2 UX contracts with render) - belief runtime instrumentation for C4/C5 flows - semantic validation boundaries and static verification workflow **If `/speckit.ux` was run before plan:** - `screen-models.md` defines Model inventory → use directly, don't re-discover - `api-ux.md` defines API shapes → use as @DATA_CONTRACT source for backend Pydantic schemas - `-ux.md` defines UX contracts → use as @UX_STATE/@UX_FEEDBACK source for component contracts - Generated `.svelte.ts` model files in `frontend/src/lib/models/` → DO NOT regenerate; reference them via `@RELATION BINDS_TO` from component contracts Write `research.md` with concise sections: - Decision - Rationale - Alternatives Considered - Impact On Contracts / Tasks Use `[NEED_CONTEXT: target]` instead of inventing relation targets, DTO names, or module boundaries that cannot be grounded in repo context. ## Phase 1: Design, ADR Continuity, and Contracts ### Frontend Model & Component Reuse Scan (MANDATORY — before contract generation) Before designing any new screen, execute a **model-first inventory scan** followed by a **component inventory scan** of the existing codebase to maximise reuse and prevent duplicate primitives. **Step 1: Screen Model scan** (use a subagent with `subagent_type: "explore"`): - Search `frontend/src/lib/models/` for existing `[TYPE Model]` contracts - Use `axiom_semantic_discovery search_contracts type="Model" query=""` for structured search - Check model atoms, actions, and invariants — reuse if the screen state maps to an existing model - New models use `.svelte.ts` extension, `[TYPE Model]` contract, `@STATE`/`@ACTION`/`@INVARIANT` tags **Step 2: Component scan** (priority order): **Scan targets** (priority order): 1. `frontend/src/lib/ui/` — design-system atoms: `Button.svelte`, `Select.svelte`, `Input.svelte`, `Card.svelte` 2. `frontend/src/lib/components/ui/` — composite UI widgets: `SearchableMultiSelect.svelte`, `MultiSelect.svelte` 3. `frontend/src/lib/components/` — feature components that may be adaptable 4. Inline patterns in existing pages (`frontend/src/routes/`) — badges, skeletons, empty states, collapsibles **For each found component, the scan MUST return:** - Exact file path - Props interface (what it accepts) - Whether it's a direct fit, adaptable, or pattern-only **Reuse decision tree:** | Situation | Action | |-----------|--------| | Component exists and fits | `@RELATION DEPENDS_ON -> [ExistingComponent]` — zero new code | | Pattern exists (badge, skeleton, tooltip) | Document the Tailwind classes to replicate; no component extraction | | No reusable asset exists | Create new component only then | **Output:** The `contracts/modules.md` for every frontend contract MUST include `@RELATION` edges to reused components/models and a `@RATIONALE` noting WHY the asset is reused rather than rebuilt. For pattern-only reuse, the contract MUST reference the source page/file where the pattern was observed. Components that bind to a Screen Model declare `@RELATION BINDS_TO -> [ModelId]`. **Forbidden patterns:** - Creating a new `` when `confirm()` suffices - Building a custom `