# feat
> This skill should be used when the user asks to 'implement a feature', 'run /feat', 'complete feature pipeline', 'add new functionality', or needs end-to-end feature development workflow with architecture, implementation, review, and PR creation.
- Author: Ngoc
- Repository: Vegarnom/mega-team-v4
- Version: 20260202115326
- Stars: 0
- Forks: 0
- Last Updated: 2026-02-06
- Source: https://github.com/Vegarnom/mega-team-v4
- Web: https://mule.run/skillshub/@@Vegarnom/mega-team-v4~feat:20260202115326
---
---
name: feat
description: This skill should be used when the user asks to 'implement a feature', 'run /feat', 'complete feature pipeline', 'add new functionality', or needs end-to-end feature development workflow with architecture, implementation, review, and PR creation.
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Task, WebFetch, WebSearch
version: 4.1
skills:
- common-patterns
- shared/model-selector
args:
- name: --fast
description: "Skip optional reviews, use faster models (sonnet instead of opus)"
- name: --turbo
description: "Maximum speed mode, minimal validation (use for prototyping only)"
- name: --quality
description: "Maximum quality, no shortcuts"
- name: --warmup
description: "Run session warmup before starting"
- name: --spec
description: "Enable spec-first mode with requirements validation (NEW v4.0)"
- name: --analyze
description: "Run consistency analysis before implementation (NEW v4.0)"
hooks:
PostToolUse:
- matcher: { tool_name: "Edit" }
command: "bash ~/.claude/scripts/post-edit-lint.sh"
- matcher: { tool_name: "Write" }
command: "bash ~/.claude/scripts/post-write-lint.sh"
PreToolUse:
- matcher: { tool_name: "Edit", file_pattern: "*.entity.ts" }
command: "bash ~/.claude/scripts/pre-entity-edit.sh"
- matcher: { tool_name: "Edit", file_pattern: "**/migrations/*.ts" }
type: prompt
prompt: "Editing migration file. Ensure migration is reversible and won't cause data loss."
SubagentStop:
- type: command
command: "bash ~/.claude/scripts/verify-agent-output.sh"
description: "Validate agent output quality and log metrics"
---
# Complete Feature Pipeline v4.1 (SpecKit + Dynamic Routing)
Execute the FULL feature development workflow with spec-first approach, requirements validation, and dynamic stack detection.
---
## WHAT'S NEW IN v4.1 (Dynamic Routing)
- **Dynamic Stack Detection**: Auto-detect framework → load correct skill/agent
- **Agent Registry**: Centralized mapping từ patterns → agents (`~/.claude/config/agent-registry.json`)
- **detect-stack.sh**: Script phát hiện stack tự động, output JSON
- **agent-router.sh**: Helper để query detected agents
- **load-skill-context.sh**: Auto-load skill files dựa trên detected stack
- **Supports 16 tech stacks**: go-zero, FastAPI, Express, NestJS, React, Vue, Next.js, Flutter, Swift, Kotlin, Prisma, K8s, Terraform, GitHub Actions, Docker, AWS
## WHAT'S NEW IN v4.0 (SpecKit Integration)
### Core Integrations from SpecKit
| Feature | Description | Flag |
|---------|-------------|------|
| **Constitution Check** | Validate against project principles | Auto |
| **Spec-First Mode** | Generate spec.md before planning | `--spec` |
| **Requirements Checklist** | Unit tests for requirements quality | `--spec` |
| **Consistency Analysis** | Cross-artifact validation | `--analyze` |
| **GitHub Issues** | Convert tasks to issues | `--issues` |
| **Traceability** | Link spec → plan → tasks → code | Auto |
### New Phase Structure
```
Phase 0: Pre-flight (unchanged)
Phase 0.5: Constitution Check (NEW)
Phase 1: Specification (NEW - optional with --spec)
├── 1.0: Generate spec.md
├── 1.1: Clarify requirements (max 5 questions)
└── 1.2: Requirements checklist validation
Phase 2: Planning (enhanced)
├── 2.1: Explore [haiku]
├── 2.2: Generate plan [opus]
├── 2.3: Architecture design
└── 2.4: Consistency analysis (NEW with --analyze)
Phase 3: Implementation (unchanged)
Phase 4: Quality (unchanged)
Phase 5: Validation (unchanged)
Phase 6: Finalization (enhanced)
├── 6.1: Generate PR
├── 6.2: Create GitHub Issues (NEW with --issues)
└── 6.3: Cleanup
```
---
## PREVIOUS VERSION FEATURES (RETAINED)
- v3.8: Workflow Optimizer, Session Warmup, Smart Pipeline
- v3.7: Parallel Execution, Predictive Prefetch
- v3.6: Speed Optimization Flags, Smart Model Selection
- v3.5: Dynamic Skill Generator
- v3.4: Executor Skill with phase-based enforcement
- v3.3: Hybrid Plan Format
- v3.2: Branch Confirmation
- v3.1: SubagentStop Hook, TRUE Parallel Execution
- v3.0: OpusPlan Model, Auto-Lint Hooks
---
## SPEED MODE COMPARISON (Updated)
| Mode | Planning | Implement | Reviews | Spec | Est. Time |
|------|----------|-----------|---------|------|-----------|
| Normal | opus | opus | All | Optional | 20-30 min |
| `--fast` | sonnet | sonnet | Essential | Skip | 12-18 min |
| `--turbo` | haiku | sonnet | Skip | Skip | 8-12 min |
| `--quality` | opus | opus | All + Extra | Full | 35-50 min |
| `--spec` | opus | opus | All | **REQUIRED** | 30-45 min |
---
## MODEL SELECTION STRATEGY (Updated)
| Phase | Task | Model | Reason |
|-------|------|-------|--------|
| Phase 0 | Pre-flight | - | Bash only |
| Phase 0.5 | Constitution check | `haiku` | Speed |
| Phase 1.0 | Generate spec | `opus` | **Quality critical** |
| Phase 1.1 | Clarify | `sonnet` | Interactive |
| Phase 1.2 | Checklist | `haiku` | Speed |
| Phase 2.1 | Explore | `haiku` | Speed |
| Phase 2.2 | Generate plan | `opus` | **Quality critical** |
| Phase 2.3 | Architecture | `opus` | **Quality critical** |
| Phase 2.4 | Analyze | `sonnet` | Balance |
| Phase 2.5 | Architect review | `sonnet` | Balance |
| Phase 3.x | Implement | `opus` | **Quality critical** |
| Phase 4.x | Code review | `sonnet` | Balance |
| Phase 5-6 | PR/Changelog | `haiku` | Speed |
---
## PHASE 0: Pre-flight Check (MANDATORY)
### Step 0.1: Parse Arguments & Detect Mode
```typescript
args = parseArgs(input)
FLAGS = {
fast: args.includes("--fast"),
turbo: args.includes("--turbo"),
quality: args.includes("--quality"),
spec: args.includes("--spec"),
analyze: args.includes("--analyze"),
issues: args.includes("--issues"),
warmup: args.includes("--warmup")
}
// Auto-enable spec mode for quality
IF FLAGS.quality:
FLAGS.spec = true
FLAGS.analyze = true
console.log(`
🚀 FEATURE PIPELINE v4.0 (SpecKit Integration)
${"=".repeat(60)}
Mode: ${determineMode(FLAGS)}
Spec-First: ${FLAGS.spec ? "ENABLED" : "disabled"}
Analyze: ${FLAGS.analyze ? "ENABLED" : "disabled"}
`)
```
### Step 0.2: Ask Issue ID, Short Description, Scope & Base Branch
```
User: /feat Add dark mode
Assistant: Cho tôi biết:
- Issue ID? (ví dụ: 456)
- Short description? (ví dụ: dark-mode)
- Scope? (Backend / Frontend / Mobile / All)
- Base branch? (mặc định: develop)
```
### Step 0.3: Confirm Branch Creation
```
Assistant: Tôi sẽ tạo branch với thông tin sau:
- Branch name: feature/issues/{issue_id}
- Base branch: {base_branch}
- Worktree: /path/to/{repo}-feat-{issue_id}
- Plan directory: .claude/plans/feat-{issue_id}/
Bạn có muốn tiếp tục không? (Y/n)
```
### Step 0.4: Setup Worktree
```bash
~/.claude/scripts/setup-worktree.sh {issue_id} {short_description} {base_branch} feat
cd "${PARENT_DIR}/${REPO_NAME}-feat-${ISSUE_ID}"
# v4.0: Enhanced plan directory structure
PLAN_DIR=".claude/plans/feat-${ISSUE_ID}"
mkdir -p "${PLAN_DIR}/details"
mkdir -p "${PLAN_DIR}/checklists"
```
### Step 0.5: Pre-flight Checks
```bash
~/.claude/scripts/smart-check.sh ${SCOPE}
npm audit --json > /tmp/npm-audit-result.json &
```
### Step 0.6: Dynamic Stack Detection (NEW v4.1)
```bash
# Auto-detect stack and cache result
STACK=$(~/.claude/scripts/detect-stack.sh "$(pwd)" --cache)
# Get recommended agents
BACKEND_AGENT=$(~/.claude/scripts/agent-router.sh backend)
FRONTEND_AGENT=$(~/.claude/scripts/agent-router.sh frontend)
MOBILE_AGENT=$(~/.claude/scripts/agent-router.sh mobile)
DEVOPS_AGENT=$(~/.claude/scripts/agent-router.sh devops)
# Load all detected skill contexts
for skill_path in $(~/.claude/scripts/load-skill-context.sh); do
$skill_path
done
echo "Detected: backend=$BACKEND_AGENT, frontend=$FRONTEND_AGENT, mobile=$MOBILE_AGENT"
```
**OUTPUT: Stack Detection Report**
```markdown
## Stack Detection ✓
| Scope | Agent Detected | Skill Loaded |
| -------- | --------------------- | ------------------------------- |
| Backend | python-fastapi | ~/.claude/skills/python-fastapi |
| Frontend | react-architect | ~/.claude/skills/react-architect|
| DevOps | kubernetes-helm | ~/.claude/skills/kubernetes-helm|
```
---
## PHASE 0.5: Constitution Check (NEW in v4.0)
**Purpose:** Validate feature against project principles before starting.
### Step 0.5.1: Load Constitution
```typescript
CONSTITUTION_FILES = [
".claude/constitution.md",
".specify/memory/constitution.md",
"PRINCIPLES.md"
]
constitution = null
FOR EACH file in CONSTITUTION_FILES:
IF exists(file):
constitution = ${file}
console.log(`📜 Loaded constitution: ${file}`)
BREAK
IF constitution == null:
console.log("ℹ️ No constitution found, skipping principles check")
SKIP Phase 0.5
```
### Step 0.5.2: Validate Against Principles
```typescript
IF constitution:
principles = extractPrinciples(constitution) // MUST/SHOULD statements
console.log(`
📜 CONSTITUTION CHECK
${"=".repeat(50)}
Principles loaded: ${principles.length}
`)
violations = []
FOR EACH principle in principles:
IF principle.type == "MUST":
conflict = checkConflict(feature_description, principle)
IF conflict:
violations.push({
principle: principle.name,
conflict: conflict,
severity: "CRITICAL"
})
IF violations.length > 0:
console.log(`
❌ CONSTITUTION VIOLATIONS DETECTED:
`)
FOR EACH v in violations:
console.log(` - ${v.severity}: ${v.principle}`)
console.log(` Conflict: ${v.conflict}`)
ASK USER: "Resolve violations before proceeding? (Y/n)"
IF user_says_no:
EXIT 1
ELSE:
console.log("✅ Feature aligns with project constitution")
```
---
## PHASE 1: Specification (NEW - Optional with --spec)
**Skip if:** `--fast`, `--turbo`, or user explicitly skips
### Step 1.0: Generate Specification
```typescript
IF FLAGS.spec:
console.log(`
${"#".repeat(60)}
📋 PHASE 1: SPECIFICATION
${"#".repeat(60)}
`)
SPEC_FILE = "${PLAN_DIR}/spec.md"
## Generate Feature Specification
Feature: ${feature_description}
Scope: ${SCOPE}
Issue: #${ISSUE_ID}
Create a specification following this structure:
### 1. Overview
- 1-2 sentence summary
- Business value
### 2. User Stories
- As a [role], I want [action] so that [benefit]
- Include priority: P1 (must), P2 (should), P3 (nice-to-have)
### 3. Functional Requirements
- Specific, testable requirements
- Use MUST/SHOULD/MAY language
- Each requirement must be verifiable
### 4. Non-Functional Requirements
- Performance targets (quantified)
- Security requirements
- Scalability considerations
### 5. Success Criteria
- Measurable outcomes (NOT implementation details)
- User-focused metrics
### 6. Out of Scope
- What we're NOT doing
### 7. Assumptions
- Dependencies and constraints
Rules:
- Focus on WHAT, not HOW
- No implementation details (frameworks, APIs, etc.)
- Written for business stakeholders
- Each requirement must be testable
${generated_spec}
console.log(`✅ Spec generated: ${SPEC_FILE}`)
```
### Step 1.1: Clarify Requirements (Interactive)
```typescript
IF FLAGS.spec AND NOT FLAGS.fast:
console.log(`
📝 CLARIFYING REQUIREMENTS
`)
// Scan spec for ambiguities
ambiguities = scanForAmbiguities(SPEC_FILE)
/*
Categories:
- Functional Scope & Behavior
- Domain & Data Model
- Interaction & UX Flow
- Non-Functional Quality Attributes
- Edge Cases & Failure Handling
*/
questions = prioritizeQuestions(ambiguities, max=5)
IF questions.length == 0:
console.log("✅ No critical ambiguities detected")
ELSE:
clarifications = []
FOR i = 0 TO min(5, questions.length):
question = questions[i]
// Present with recommendation
console.log(`
**Question ${i+1}/${questions.length}: ${question.category}**
${question.text}
**Recommended:** ${question.recommended} - ${question.rationale}
| Option | Description |
|--------|-------------|
${question.options.map((o, idx) => `| ${String.fromCharCode(65+idx)} | ${o} |`).join('\n')}
Reply with option letter, "recommended", or custom answer (≤5 words):
`)
answer = AWAIT user_response
IF answer == "recommended" OR answer == "yes":
answer = question.recommended
clarifications.push({ question: question.text, answer: answer })
// Update spec immediately
updateSpecWithClarification(SPEC_FILE, question, answer)
// Add clarifications section to spec
appendClarificationsSection(SPEC_FILE, clarifications)
```
### Step 1.2: Requirements Checklist (Unit Tests for English)
```typescript
IF FLAGS.spec:
console.log(`
📋 REQUIREMENTS QUALITY CHECKLIST
`)
CHECKLIST_FILE = "${PLAN_DIR}/checklists/requirements.md"
// Generate checklist that tests REQUIREMENTS quality, not implementation
checklist = generateRequirementsChecklist(SPEC_FILE)
/*
Example items (CORRECT - testing requirements):
- [ ] CHK001 - Are performance requirements quantified with specific metrics? [Clarity]
- [ ] CHK002 - Are error handling requirements defined for all failure modes? [Completeness]
- [ ] CHK003 - Are user roles and permissions clearly differentiated? [Completeness]
- [ ] CHK004 - Can success criteria be objectively measured? [Measurability]
NOT (WRONG - testing implementation):
- [ ] Verify button clicks work correctly
- [ ] Test API returns 200
*/
# Requirements Quality Checklist: ${feature_description}
**Purpose**: Validate specification completeness and quality
**Created**: ${new Date().toISOString().split('T')[0]}
**Spec**: ${SPEC_FILE}
## Requirement Completeness
${checklist.completeness.map(item => `- [ ] ${item}`).join('\n')}
## Requirement Clarity
${checklist.clarity.map(item => `- [ ] ${item}`).join('\n')}
## Acceptance Criteria Quality
${checklist.acceptance.map(item => `- [ ] ${item}`).join('\n')}
## Edge Case Coverage
${checklist.edgeCases.map(item => `- [ ] ${item}`).join('\n')}
---
**Status**: Pending validation
// Auto-validate checklist
validationResults = validateChecklist(SPEC_FILE, checklist)
failures = validationResults.filter(r => !r.passed)
IF failures.length > 0:
console.log(`
⚠️ ${failures.length} checklist items need attention:
`)
FOR EACH failure in failures:
console.log(` - ${failure.item}: ${failure.issue}`)
ASK USER: "Fix spec issues before planning? (Y/n)"
IF user_says_yes:
fixSpecIssues(SPEC_FILE, failures)
ELSE:
console.log("✅ All requirements quality checks passed")
// Mark checklist complete
old: "**Status**: Pending validation"
new: "**Status**: ✅ Validated"
```
**CHECKPOINT 0.5**
```markdown
# .claude/checkpoints/feat-{ISSUE_ID}.md
Status: CHECKPOINT_0.5_COMPLETE
Constitution: Checked ✅
Spec: ${SPEC_FILE} (if --spec)
Checklist: ${CHECKLIST_FILE} (if --spec)
Ready for: Planning
```
---
## PHASE 2: Research & Planning (Enhanced)
### Step 2.1: Explore & Understand
```typescript
console.log(`
${"#".repeat(60)}
📦 PHASE 2: PLANNING
${"#".repeat(60)}
`)
// Use cache if available
CACHE_RESULT = $(~/.claude/scripts/cache-context.sh "$(pwd)")
IF cache_hit:
PATTERNS = CACHE_RESULT.patterns
STRUCTURE = CACHE_RESULT.structure
console.log("📦 Using cached context (skipping explore)")
ELSE:
Find patterns for: ${feature_description}
Look for: similar features, related modules, reusable code
```
### Step 2.2: Generate Plan
```typescript
## Generate Implementation Plan
${FLAGS.spec ? `Specification: ${SPEC_FILE}` : `Feature: ${feature_description}`}
Scope: ${SCOPE}
Issue: #${ISSUE_ID}
${FLAGS.spec ? "Use the specification as the source of truth for requirements." : ""}
Create a detailed implementation plan...
PLAN_FILE = "${PLAN_DIR}/PLAN.md"
${generated_plan}
```
### Step 2.3: Architecture Design
```typescript
## Architecture Review
Plan: ${PLAN_FILE}
${FLAGS.spec ? `Spec: ${SPEC_FILE}` : ""}
Review and enhance:
1. Data models and relationships
2. API design (RESTful best practices)
3. Component structure
4. Error handling strategy
5. Performance considerations
${FLAGS.spec ? "Ensure architecture supports all spec requirements." : ""}
```
### Step 2.4: Consistency Analysis (NEW - Optional with --analyze)
```typescript
IF FLAGS.analyze:
console.log(`
📊 CONSISTENCY ANALYSIS
${"=".repeat(50)}
`)
## Cross-Artifact Consistency Analysis
Artifacts:
- ${FLAGS.spec ? `Spec: ${SPEC_FILE}` : "Feature description"}
- Plan: ${PLAN_FILE}
${constitution ? `- Constitution: ${CONSTITUTION_FILE}` : ""}
Perform analysis:
### A. Duplication Detection
- Identify near-duplicate requirements
- Flag inconsistent terminology
### B. Ambiguity Detection
- Flag vague terms without measurable criteria
- Identify unresolved placeholders (TODO, TBD, etc.)
### C. Coverage Gaps
- Requirements with no planned implementation
- Planned work not tied to requirements
### D. Constitution Alignment
- Any plan element conflicting with MUST principles
- Missing mandated quality gates
### E. Inconsistency
- Terminology drift (same concept, different names)
- Conflicting technical decisions
Output format:
| ID | Category | Severity | Location | Summary | Recommendation |
|----|----------|----------|----------|---------|----------------|
Severity: CRITICAL (must fix), HIGH (should fix), MEDIUM (consider), LOW (optional)
analysis_results = parseAnalysisResults(analysis_output)
critical_issues = analysis_results.filter(r => r.severity == "CRITICAL")
IF critical_issues.length > 0:
console.log(`
❌ ${critical_issues.length} CRITICAL issues found:
`)
FOR EACH issue in critical_issues:
console.log(` - ${issue.id}: ${issue.summary}`)
ASK USER: "Fix critical issues before implementation? (Y/n)"
IF user_says_yes:
// Fix issues in plan or spec
fixCriticalIssues(critical_issues)
ELSE:
console.log("✅ No critical consistency issues found")
// Save analysis report
# Consistency Analysis Report
${analysis_output}
**Generated**: ${new Date().toISOString()}
```
### Step 2.5: Architect Review (DYNAMIC ROUTING - v4.1)
```typescript
// Dynamic agent selection based on detected stack
BACKEND_AGENT=$(~/.claude/scripts/agent-router.sh backend)
FRONTEND_AGENT=$(~/.claude/scripts/agent-router.sh frontend)
MOBILE_AGENT=$(~/.claude/scripts/agent-router.sh mobile)
IF NOT FLAGS.turbo:
// Backend review (dynamic)
IF BACKEND_AGENT != "":
Review ${PLAN_FILE} for ${BACKEND_AGENT} patterns...
// Frontend review (dynamic)
IF FRONTEND_AGENT != "":
Review ${PLAN_FILE} for ${FRONTEND_AGENT} patterns...
// Mobile review (dynamic)
IF MOBILE_AGENT != "":
Review ${PLAN_FILE} for ${MOBILE_AGENT} patterns...
// Universal agents (always run)
Scan for vulnerabilities...
Check code quality...
```
**CHECKPOINT 1**
```markdown
Status: CHECKPOINT_1_COMPLETE
Spec: ${SPEC_FILE} (if --spec)
Plan: ${PLAN_FILE}
Analysis: analysis-report.md (if --analyze)
Architecture: Approved
```
**→ ASK USER: Review plan before proceeding?**
---
## PHASE 3: Development (Unchanged from v3.8)
### Step 3.1: Load Reference Patterns (DYNAMIC - v4.1)
```bash
# Automatically load skill contexts based on detected stack
for skill_path in $(~/.claude/scripts/load-skill-context.sh); do
$skill_path
done
```
### Step 3.2: Implement Feature
```typescript
// v4.0: Enhanced with spec traceability
## Implementation Context
Plan: ${PLAN_FILE}
${FLAGS.spec ? `Spec: ${SPEC_FILE}` : ""}
${FLAGS.spec ? `
## Traceability Requirements
Each implementation must link to a spec requirement:
- Comment format: // REQ: [requirement-id]
- Test format: describe("[REQ-001] Feature X", () => {...})
` : ""}
Implement the feature according to PLAN.md
```
### Step 3.3: Database Migration (If needed)
```
IF plan includes DB changes:
Run: /migration --name {FeatureName}
```
### Step 3.4: Multi-Agent Code Review
```typescript
IF USE_ENHANCED_REVIEW:
/review --staged
ELSE:
// Standard parallel review
...
...
```
**CHECKPOINT 2**
---
## PHASE 4: Testing & Quality (MEGA-PARALLEL)
```bash
# Parallel validation
~/.claude/scripts/parallel-validate.sh ${FLAGS.fast ? "--fast" : ""}
```
### Quality Metrics Dashboard
```markdown
┌────────────────┬─────────┬─────────┬───────────┐
│ Metric │ Before │ After │ Status │
├────────────────┼─────────┼─────────┼───────────┤
│ Test Coverage │ 78% │ 85% │ ✓ +7% │
│ TS Errors │ 0 │ 0 │ ✓ │
│ Lint Issues │ 3 │ 0 │ ✓ -3 │
│ Spec Coverage │ - │ 100% │ ✓ (v4.0) │
└────────────────┴─────────┴─────────┴───────────┘
```
---
## PHASE 5: Validation (Enhanced with Spec Traceability)
```typescript
IF FLAGS.spec:
console.log(`
📋 SPEC TRACEABILITY VALIDATION
`)
// Check each requirement has implementation
requirements = extractRequirements(SPEC_FILE)
implementations = findImplementations()
coverage = []
FOR EACH req in requirements:
impl = implementations.find(i => i.links_to(req.id))
coverage.push({
requirement: req,
implemented: !!impl,
file: impl?.file,
test: impl?.test
})
uncovered = coverage.filter(c => !c.implemented)
IF uncovered.length > 0:
console.log(`
⚠️ ${uncovered.length} requirements not traced to implementation:
`)
FOR EACH uc in uncovered:
console.log(` - ${uc.requirement.id}: ${uc.requirement.text}`)
ELSE:
console.log("✅ All spec requirements traced to implementation")
```
### Multi-Agent Validation (PARALLEL)
```typescript
/feature-validate
...
...
```
**CHECKPOINT 3**
---
## PHASE 6: Finalization (Enhanced)
### Step 6.1: Generate PR & Changelog
```typescript
/feature-pr
/feature-changelog
```
### Step 6.2: Create GitHub Issues (NEW - Optional with --issues)
```typescript
IF FLAGS.issues:
console.log(`
🎫 CREATING GITHUB ISSUES
`)
// Check if repo has GitHub remote
remote = git config --get remote.origin.url
IF remote.includes("github.com"):
tasks = extractTasks(PLAN_FILE)
FOR EACH task in tasks:
## Create GitHub Issue
Task: ${task.title}
Description: ${task.description}
Labels: ${task.labels.join(", ")}
Milestone: Feature #${ISSUE_ID}
Create issue using gh CLI:
gh issue create --title "${task.title}" --body "${task.description}"
console.log(`✅ Created ${tasks.length} GitHub issues`)
ELSE:
console.log("⚠️ Not a GitHub repository, skipping issue creation")
```
### Step 6.3: Create PR
```bash
git push -u origin feature/issues/{issue_id}
gh pr create --title "feat: {description}" --body "{pr_body}"
```
### Step 6.4: Final Quality Report
```markdown
## Quality Report v4.0
### Spec Traceability (NEW)
| Requirement | Implemented | Tested |
|-------------|-------------|--------|
${FLAGS.spec ? requirements.map(r => `| ${r.id} | ✅ | ✅ |`).join('\n') : "N/A - Spec mode not enabled"}
### Constitution Compliance
${constitution ? "✅ All principles respected" : "N/A - No constitution"}
### Metrics Dashboard
┌────────────────┬─────────┬─────────┬───────────┐
│ Metric │ Before │ After │ Status │
├────────────────┼─────────┼─────────┼───────────┤
│ Test Coverage │ 78% │ 85% │ ✓ +7% │
│ TS Errors │ 0 │ 0 │ ✓ │
│ Lint Issues │ 3 │ 0 │ ✓ -3 │
└────────────────┴─────────┴─────────┴───────────┘
```
### Step 6.5: Cleanup
```bash
# v4.0: Enhanced cleanup
rm -rf ${PLAN_DIR}/details/
rm -f ${PLAN_DIR}/.progress-*.json
rm -f .claude/checkpoints/feat-{issue_id}.md
# Keep for reference:
# - ${PLAN_DIR}/PLAN.md
# - ${PLAN_DIR}/spec.md (if --spec)
# - ${PLAN_DIR}/checklists/requirements.md (if --spec)
# - ${PLAN_DIR}/analysis-report.md (if --analyze)
```
---
## EXECUTION SUMMARY
```
OPTIMIZED FLOW v4.0 (with SpecKit Integration):
Phase 0: Pre-flight (1 min)
├── Parse flags (--spec, --analyze, --issues)
├── Ask Issue ID + Short Description + Scope
├── Create Worktree
└── Pre-flight checks [PARALLEL]
Phase 0.5: Constitution Check (NEW, 30s)
└── Validate against project principles
Phase 1: Specification (NEW, 5-10 min, --spec only)
├── Generate spec.md [opus]
├── Clarify requirements (max 5 questions)
└── Requirements checklist validation
CHECKPOINT 0.5 ─────────────────
Phase 2: Planning (3-7 min)
├── Explore Agent [haiku]
├── Generate plan [opus]
├── Architecture design [opus]
├── Consistency analysis (NEW, --analyze)
└── Architect Review [PARALLEL, sonnet]
CHECKPOINT 1 ─────────────────
Phase 3: Development (10-25 min)
├── Load reference patterns
├── feature-developer [opus]
├── /migration (if DB changes)
└── Multi-agent review
CHECKPOINT 2 ─────────────────
Phase 4: Quality [MEGA-PARALLEL] (2-3 min)
├── test + lint + tsc [PARALLEL]
└── Quality metrics dashboard
Phase 5: Validation (2-5 min)
├── Spec traceability check (NEW, --spec)
├── /feature-validate
└── Multi-agent review [PARALLEL]
CHECKPOINT 3 ─────────────────
Phase 6: Finalization (1-2 min)
├── /feature-pr [haiku]
├── /feature-changelog [haiku]
├── Create GitHub Issues (NEW, --issues)
└── Cleanup
TOTAL TIME:
- Normal (no --spec): 20-30 min
- With --spec: 30-45 min
- With --quality (full): 35-50 min
- With --fast: 12-18 min
- With --turbo: 8-12 min
```
---
## EXECUTION RULES (Updated)
1. **ALWAYS Pre-flight first** - Check git, deps, scope
2. **ALWAYS ask Issue ID + Scope** - Before creating branch
3. **CONSTITUTION CHECK** - Validate principles (NEW v4.0)
4. **SPEC-FIRST** (with --spec) - Requirements before code (NEW v4.0)
5. **CHECKLIST VALIDATION** - Unit tests for requirements (NEW v4.0)
6. **CONSISTENCY ANALYSIS** (with --analyze) - Cross-artifact check (NEW v4.0)
7. **ARCHITECTURE-FIRST** - Design before coding
8. **MEGA-PARALLEL when possible** - Single message, multiple Tasks
9. **SMART SKIP** - Only run relevant architects
10. **LOAD REFERENCES** - Read patterns before coding
11. **AUTO-LINT** - Hooks handle formatting
12. **CHECKPOINT after major phases** - Enable resume
13. **SPEC TRACEABILITY** - Link requirements to code (NEW v4.0)
14. **GITHUB ISSUES** (with --issues) - Convert tasks to issues (NEW v4.0)
---
## REFERENCE FILES
| File/Skill | When to Use |
|------------|-------------|
| `/go-zero-patterns` skill | Backend (go-zero microservices) |
| `/react-architect` skill | Frontend (React 19 + TanStack) |
| `/tanstack-query-optimizer` skill | Query caching, mutations |
| `/vietmap-integration` skill | VietMap GL JS, GIS features |
| `references/flutter-patterns.md` | Mobile (Flutter) |
| `references/testing-guide.md` | Writing tests |
---
## CONSTITUTION TEMPLATE (Create at .claude/constitution.md)
```markdown
# Project Constitution
## Core Principles
### MUST Requirements (Non-negotiable)
1. **Security First**
- All user input MUST be validated
- All sensitive data MUST be encrypted
- All endpoints MUST be authenticated
2. **Quality Standards**
- All code MUST pass TypeScript strict mode
- All features MUST have >80% test coverage
- All APIs MUST follow RESTful conventions
3. **Performance**
- API responses MUST be <200ms p95
- Page loads MUST be <3s on 3G
### SHOULD Requirements (Recommended)
1. Features SHOULD be backwards compatible
2. Database changes SHOULD have rollback migrations
3. UI components SHOULD follow accessibility guidelines
## Governance
- Version: 1.0.0
- Last Updated: YYYY-MM-DD
- Amendment Process: PR with team review
```
---
## GIT COMMIT RULES
**Do NOT include Co-Authored-By line.**
```bash
git commit -m "$(cat <<'EOF'
feat():
EOF
)"
```