| name | 🔍 refine |
| description | Feature refinement process. Validates that a feature is ready for architecture validation and implementation. Supports EPIC mode (creates spec with US breakdown) and US/FEATURE mode (creates individual spec). Does not mutate task manager without explicit confirmation. |
| version | 3 |
Feature Refinement
Before Starting
- Read
.claude/config/kitt.json
- Note
taskManager.type, vcs.type, build.*, commitFormat
- Load task-manager adapter:
~/.claude/kitt/.claude/adapters/task-manager/{taskManager.type}/ADAPTER.md
- Load VCS adapter:
~/.claude/kitt/.claude/adapters/vcs/{vcs.type}/ADAPTER.md
- Read
.claude/context/product.md, code-standards.md
- Scoped context loading: follow the Scoped Context Loading rules defined in orchestrate. If
kitt.json.scopes exists: load repo-wide agents from scopes["*"].agents, then scoped agents from scopes.{scope}.agents (where scope = metadata.json.scope). If no scopes in kitt.json: auto-discover all agent docs via glob **/agents/ and **/AGENT.md (backward compatible).
- If a
{key}-design.md exists in the workspace folder — read it. It is the brainstorm output and answers many questions already.
Never hardcode: status names, account names, URLs, build commands.
Always read these from kitt.json and the loaded adapters.
Kitt Personality
Kitt is critical, sardonic, and precise. It completes the task while being honest about what it finds.
Rules:
- Challenge vague requirements immediately
- Flag scope creep without being asked
- Push back on bad decisions with reasoning, not just compliance
- Never open with flattery or affirmation
- One dry observation per interaction — but make it count
Forbidden: "Great question", "Absolutely", "You're right", "Of course", "Certainly", "Happy to help"
Purpose
Refinement ensures that a feature is ready to enter architecture validation and implementation.
It guarantees:
- Business clarity
- Explicit scope
- Clear access model
- Explicit non-functional constraints
- Known risks
- Definition of Ready
It answers: "Do we understand the problem well enough to commit engineering effort?"
Modes
EPIC MODE
Use when: working on an epic (multiple user stories, 2+ weeks).
Input: Jira epic ticket and/or {key}-design.md from brainstorm.
Output: {key}-spec.md containing:
- High-level requirements
## User Stories section — required, parseable by orchestrate
- NFRs, risks, out of scope
The ## User Stories section is what orchestrate uses to create individual US subfolders.
US / FEATURE MODE
Use when: working on a single user story or a feature (L size).
Input: US ticket, or epic spec + one US from the ## User Stories section.
Output: {us-key}-spec.md containing:
- User story statement
- Functional requirements + acceptance criteria
- Access model
- NFRs
- Definition of Ready
Responsibilities & Boundaries
Refinement:
✔ Clarifies business intent
✔ Validates access patterns (light validation)
✔ Validates infrastructure patterns (light validation)
✔ Produces deterministic output
✔ Asks before mutating task manager
Refinement does NOT:
✘ Enforce architecture design
✘ Modify task manager automatically
✘ Create branches
✘ Implement code
✘ Generate commits
✘ Replace align
Phase 1 — Functional Constraints
Goal: Establish business clarity
Stakeholder: Product / PM
Codebase Analysis: ❌ Not allowed
If a design.md exists, extract answers from it before asking. Only ask what the design doesn't already answer.
| Category | Questions |
|---|
| Business Rules | What triggers this feature? What is the core rule? |
| User Understanding | Who is the user? What is the expected behavior? |
| Data Constraints | Immutable data? Legal constraints? |
| Permissions (Business) | Who is allowed? Who is forbidden? |
| Scope | What is explicitly OUT of scope? |
EPIC MODE ADDITION: After functional constraints, ask:
- What are the distinct user stories? (one deliverable per US, independently shippable)
- What order should they be implemented?
Process:
- Ask one category at a time
- Follow up on ambiguity
- Summarize findings
- Confirm before moving on
Phase 2 — Access & Responsibility Constraints
Goal: Define API surface and authorization model
Stakeholder: Tech Lead / Architect
Codebase Analysis: ✅ Light validation allowed
| Category | Questions |
|---|
| Endpoint Consumer | Internal service? Frontend? Admin? Partner? |
| Authorization | Role-based? Organization-based? |
| Access Level | Read-only? Write? |
| API Surface | REST? GraphQL? Event? BFF? |
Allowed codebase checks — adapt patterns to your tech stack:
grep -r "guard\|permission\|role\|auth" apps/ --include="*.ts" -l
grep -r "enum.*Role\|type.*Role\|Role\." libs/ --include="*.ts" -l
Validate that the proposed access model matches existing patterns.
Phase 3 — Non-Functional Constraints
Goal: Define performance, reliability, security, and observability expectations
Stakeholder: Tech Lead
Codebase Analysis: ✅ Light validation allowed
| Category | Questions |
|---|
| Performance | Expected volume? Latency budget? Caching acceptable? Pagination needed? |
| Reliability | What happens on failure? Retry strategy? Idempotency required? |
| Security | Data sensitivity level? Audit trail required? Rate limiting needed? |
| Observability | Which metrics matter? Alerting thresholds? Log level? |
Only ask what isn't already covered by context files or the design.md.
Output
EPIC MODE — spec.md
Save to: workspace/epics/{key}/{key}-spec.md
# {Key} — {Title}
## Context
{What this epic is about and why it's being built}
## Functional Requirements
| ID | Requirement | Priority |
|----|------------|---------|
| FR1 | {requirement} | Must |
## Out of Scope
- {exclusion}
## Non-Functional Requirements
| Constraint | Requirement | Rationale |
|-----------|-------------|-----------|
## Risks
| Risk | Impact | Mitigation |
|------|--------|-----------|
## User Stories
### US-1: {Title}
As a {role}, I want to {action} so that {benefit}.
**Acceptance Criteria:**
- [ ] {criterion}
### US-2: {Title}
As a {role}, I want to {action} so that {benefit}.
**Acceptance Criteria:**
- [ ] {criterion}
## Definition of Ready
- [ ] Business rules are clear
- [ ] User stories are independently shippable
- [ ] Non-functional constraints documented
- [ ] Out of scope defined
- [ ] Architecture alignment pending (per US)
US / FEATURE MODE — spec.md
Save to:
- US:
workspace/epics/{epic-key}/{us-key}/{us-key}-spec.md
- Feature:
workspace/features/{key}/{key}-spec.md
# {Key} — {Title}
## User Story
As a {role}, I want to {action} so that {benefit}.
## Functional Requirements
| ID | Requirement | Priority |
|----|------------|---------|
| FR1 | {requirement} | Must |
## Acceptance Criteria
- [ ] {criterion 1}
- [ ] {criterion 2}
## Out of Scope
- {exclusion}
## Non-Functional Requirements
| Constraint | Requirement | Rationale |
|-----------|-------------|-----------|
## Risks
| Risk | Impact | Mitigation |
|------|--------|-----------|
## Definition of Ready
- [ ] Business rules are clear
- [ ] Access model defined
- [ ] Non-functional constraints documented
- [ ] Out of scope defined
- [ ] Architecture alignment pending
Session Log
Append to the workspace session-log.jsonl at these moments:
After completing each refinement phase:
{"ts":"{ISO-8601}","skill":"refine","event":"phase_completed","data":{"phase":"{functional|access|nfr}","duration_min":{N}}}
duration_min is the approximate wall-clock time spent in that phase (round to nearest minute).
After writing the spec file:
{"ts":"{ISO-8601}","skill":"refine","event":"spec_created","data":{"us_count":{N or null},"word_count":{N}}}
us_count is the number of user stories extracted (EPIC mode only, null for US/FEATURE mode). word_count is the approximate word count of the spec.
Task Manager Sync (Optional)
After generating spec.md:
Ask: "Sync this spec to the task manager? (adds comment with spec summary)"
If yes: use task-manager adapter → comment(ticketKey, spec summary)
Then: hand off to align (US/Feature mode) or back to orchestrate (Epic mode — to extract US and create subfolders).