From 41ffea5f548c063d646b195dd8e82b8346f370ee Mon Sep 17 00:00:00 2001 From: Muhammad Ubaid Raza Date: Wed, 23 Jul 2025 20:07:44 +0500 Subject: [PATCH] feat: :art: add steerring docs, workflow for simple tasks --- .../spec-driven-workflow.instructions.md | 266 +++++++++++------- 1 file changed, 162 insertions(+), 104 deletions(-) diff --git a/instructions/spec-driven-workflow.instructions.md b/instructions/spec-driven-workflow.instructions.md index fa3947a..2cd33bb 100644 --- a/instructions/spec-driven-workflow.instructions.md +++ b/instructions/spec-driven-workflow.instructions.md @@ -5,7 +5,7 @@ applyTo: '**' # Spec Driven Workflow v5 -You must follow a robust, interactive approach to software development. Clarify all requirements before implementation to eliminate ambiguity. Prioritize safety and transparency by producing and maintaining structured artifacts and clear protocols. Proactively identify and handle edge cases rather than waiting for them to emerge. +You must follow a robust, systematic approach to software development. Clarify all requirements before implementation to eliminate ambiguity. Prioritize safety and transparency by producing and maintaining structured artifacts and clear protocols. Proactively identify and handle edge cases rather than waiting for them to emerge. --- @@ -24,24 +24,37 @@ You must follow a robust, interactive approach to software development. Clarify ### Required Artifacts +activity_log.md: Task summaries, deviations, reflections, completion, escalation logs. +design.md: Architecture, interfaces, mitigations. +tasks.md: Task plans, status, edge case outcomes. +edge_cases.md: Edge case matrix (description, likelihood, impact, risk score, mitigation). +requirements.md: User stories, acceptance criteria in EARS notation. +/spec/agent_work/: Archive for intermediate files. +steering/*.md: Steering instructions for design. + +- `activity_log.md`: Log decisions and actions with context, options, rationale, and execution outcomes. - `requirements.md`: Capture user stories and acceptance criteria in structured EARS notation. +- `edge_cases.md`: Edge case matrix (description, likelihood, impact, risk score, mitigation). - `design.md`: Document technical architecture, sequence diagrams, and implementation considerations. - `tasks.md`: Provide detailed implementation plans with discrete, trackable tasks. -- `activity_log.md`: Log decisions and actions with context, options, rationale, and execution outcomes. - `steering/*.md`: Store steering documents. Use multiple steering files to separate focused instructions. +- `/spec/agent_work/`: Archive for intermediate files. ### File Structure -``` +```md /spec/ -├── steering/*.md -├── requirements.md -├── design.md -├── tasks.md -└── activity_log.md +├── steering/ +│ └── *.md # Steering instructions for reusable patterns and policies +├── agent_work/ # Archive for intermediate files +├── requirements.md # User stories and acceptance criteria in EARS notation +├── design.md # Technical architecture, interfaces, and mitigations +├── tasks.md # Implementation plans with trackable tasks and status +├── edge_cases.md # Edge case matrix (description, likelihood, impact, risk score, mitigation) +└── activity_log.md # Decisions, actions, reflections, escalations, and completion logs ``` -### Maintain Files +### Maintenance Guidelines - Update artifacts for new, updated, or obsolete tasks. - Update steering docs when decisions or user prompts indicate reusable patterns or global policies. @@ -49,81 +62,138 @@ You must follow a robust, interactive approach to software development. Clarify --- -## Execution Workflow (6 Phases) +## Workflows + +### Main Workflow + +Structured process for complex, high-risk tasks requiring thorough analysis and validation. + +#### Criteria + +Use when **any** of the following are met: + +- **Scope**: Spans multiple components, modules, or files, or involves external dependencies. +- **Impact**: Affects critical functionality (e.g., core logic, data integrity, user-facing features). +- **Risk Score**: ≥30 (likelihood × impact, per edge case matrix). +- **Edge Cases**: Multiple or complex edge cases (e.g., new error states, system interactions). +- **Ambiguity**: Requirements unclear or need clarification. + +#### Steps 1. **ANALYZE** - - Read code, docs, tests, and logs. Summarize findings. - - Define requirements using EARS notation. - - Identify dependencies, constraints, and data flows. - - Catalog edge cases in a matrix with description, likelihood, impact, risk score, and mitigation. - - Assess confidence score (0–100%). - - Halt if ambiguous. Request clarification. + - Read: code, docs, tests, logs. + - Summarize: findings in `activity_log.md`. + - Define: requirements in EARS notation in `requirements.md`. + - Identify: dependencies, constraints, data flows. + - Catalog: edge cases in matrix (`edge_cases.md`): + - Fields: description, likelihood (1–5), impact (1–5), risk score (likelihood × impact), mitigation. + - Assess: confidence score (0–100%). + - Action: halt and request clarification if ambiguous. 2. **DESIGN** - - Use high confidence (>85%) to plan with edge case mitigations. - - Use medium confidence (66–85%) to build PoC/MVP. - - Use low confidence (<66%) to research and simulate edge cases. - - Document architecture, interfaces, and mitigations in `design.md`. - - Define unit tests for edge cases. - - Plan tasks in `tasks.md`. - - Apply available steering instructions. + - High confidence (>85%): plan with edge case mitigations. + - Medium confidence (66–85%): build PoC/MVP. + - Low confidence (<66%): research and simulate edge cases. + - Document: architecture, interfaces, mitigations in `design.md`. + - Define: unit tests for edge cases. + - Plan: tasks in `tasks.md`. + - Apply: steering instructions from `steering/*.md`. 3. **IMPLEMENT** - - Code in small, testable increments. - - Build from dependencies upward. - - Follow conventions and log deviations in `activity_log.md`. - - Add intent comments. - - Update `tasks.md` with status and edge case outcomes. + - Code: in small, testable increments. + - Build: from dependencies upward. + - Follow: conventions, log deviations in `activity_log.md`. + - Add: intent comments in code. + - Update: `tasks.md` with status and edge case outcomes. 4. **VALIDATE** - - Run tests and log results, including edge cases. - - Perform linting and type checking; log results. - - Verify performance and log traces. - - Resolve all issues before proceeding. + - Run: tests, log results in `activity_log.md` (include edge cases). + - Perform: linting, type checking; log results. + - Verify: performance, log traces. + - Resolve: all issues before proceeding. 5. **REFLECT** - - Refactor for maintainability and document changes. - - Update artifacts, including edge case documentation. - - Update task status in `tasks.md`. - - Log reflections in `activity_log.md`. - - Identify improvements, technical debt, and missed edge cases. - - Validate success criteria and edge case outcomes. + - Refactor: for maintainability, document changes. + - Update: artifacts, including `edge_cases.md`. + - Update: `tasks.md` with task status. + - Log: reflections in `activity_log.md`. + - Identify: improvements, technical debt, missed edge cases. + - Validate: success criteria and edge case outcomes. 6. **HANDOFF** - - Generate executive summary: task outcomes, decisions, edge case mitigations, and validation results. - - Prepare pull request: summary, changelog, and validation/artifact links. - - Archive intermediate files to `/spec/agent_work/`. - - Document completion in `activity_log.md`. + - Generate: executive summary (task outcomes, decisions, mitigations, validation results). + - Prepare: pull request (summary, changelog, validation/artifact links). + - Archive: intermediate files to `/spec/agent_work/`. + - Log: completion in `activity_log.md`. ---- +### Lightweight Workflow -## Interruption/Resume +Streamlined process for small, low-risk tasks with minimal overhead. -- Reassess system impact. -- Update artifacts (`design.md`, `tasks.md`, `activity_log.md`). -- Log event in `activity_log.md`. +#### Criteria -## Troubleshooting +Use when **all** criteria are met: -- Reanalyze requirements and edge cases. -- Update design and tasks for new mitigations. -- Retry with updated logic. -- Escalate persistent issues and log them. +- **Scope**: Single component/module/file, no external dependencies. +- **Impact**: Low, affects non-critical functionality (e.g., UI tweaks, typo fixes). +- **Risk Score**: <30 (likelihood × impact, per edge case matrix). +- **Edge Cases**: Minimal or none (no new error states or system interactions). -## Technical Debt +#### Steps -- Log technical debt in `activity_log.md` with title, priority, location, reason, impact, remediation, and effort. -- Prioritize by risk and effort. +1. **ANALYZE** + - Confirm: task meets lightweight criteria. + - Log: task and criteria assessment in `activity_log.md`. + - Identify: edge cases (if any), document in `edge_cases.md` or as a section in `activity_log.md` if minimal. + - Action: escalate to Main Workflow if ambiguities or risks emerge. + +2. **IMPLEMENT** + - Code: in small, testable increments. + - Follow: conventions, log deviations in `activity_log.md`. + - Add: intent comments in code. + +3. **VALIDATE** + - Run: relevant tests (unit, integration), log results in `activity_log.md`. + - Perform: linting, type checking; log results. + - Resolve: all issues before proceeding. + +4. **REFLECT** + - Document: changes and outcomes in `activity_log.md`. + - Identify: technical debt, missed edge cases (log with priority, impact, remediation in `activity_log.md`). + - Confirm: task completion against success criteria. + +5. **HANDOFF** + - Log: completion in `activity_log.md` (summary, validation results, edge case outcomes). + - Prepare: pull request (summary, link to `activity_log.md`). + - Archive: intermediate notes to `/spec/agent_work/`. + +### Interruption/Resume + +- Check: task status in `tasks.md` and validate artifact consistency (`requirements.md`, `design.md`, `edge_cases.md`). +- Reassess: system impact and update artifacts (`design.md`, `tasks.md`, `activity_log.md`). +- Log: interruption/resume event in `activity_log.md` with context and next steps. + +### Troubleshooting + +- Reanalyze: requirements and edge cases in `requirements.md` and `edge_cases.md`. +- Update: `design.md` and `tasks.md` for new mitigations. +- Retry: with updated logic. +- Escalate: persistent issues by logging with `[ESCALATE]` tag in `activity_log.md` and notifying human operator. + +### Technical Debt + +- Log: in `activity_log.md` with title, priority, location, reason, impact, remediation, and effort. +- Prioritize: by risk and effort. ## Quality Assurance -- Perform static analysis: check architecture and vulnerabilities. -- Perform dynamic analysis: monitor runtime and performance. -- Verify documentation for completeness and accuracy. -- Track edge case mitigations in matrix. -- Measure edge case risk reduction after mitigation. -- Validate steering instructions in `steering/*.md` and log their outcomes. -- Ensure global decisions propagate to `steering/*.md` and not only to `activity_log.md`. +- Perform: static analysis (architecture, vulnerabilities). +- Perform: dynamic analysis (runtime, performance). +- Verify: documentation completeness and accuracy. +- Track: edge case mitigations in `edge_cases.md`. +- Measure: edge case risk reduction post-mitigation. +- Validate: steering instructions in `steering/*.md` and log outcomes in `activity_log.md`. +- Ensure: global decisions propagate to `steering/*.md`. ## Few-Shot Examples for Artifacts @@ -136,64 +206,52 @@ You must follow a robust, interactive approach to software development. Clarify - req-002: IF input has invalid syntax, AGENT SHALL return error with specific hints. Priority: High, Status: Active - req-003: WHILE session storage is active, AGENT SHALL persist command context in browser. Priority: Medium, Status: Active +### edge_cases.md +```md **Edge Case Matrix** | ID | Description | Likelihood | Impact | Risk Score | Mitigation | | -------- | ------------------------------------------- | ---------- | ------ | ---------- | ------------------------------------------- | -| edge-001 | Invalid syntax in form (e.g., bad JSON/CSS) | Frequent | High | 85 | Validate input; return clear error messages | -| edge-002 | Session storage mismatch (e.g., expired) | Occasional | High | 75 | Verify storage; prompt re-authentication | -| edge-003 | Vague form input (e.g., "make webpage") | Occasional | Medium | 60 | Prompt for specific details in UI | +| edge-001 | Invalid syntax in form (e.g., bad JSON/CSS) | 4 | 5 | 20 | Validate input; return clear error messages | +| edge-002 | Session storage mismatch (e.g., expired) | 3 | 5 | 15 | Verify storage; prompt re-authentication | +| edge-003 | Vague form input (e.g., "make webpage") | 3 | 4 | 12 | Prompt for specific details in UI | ``` ### design.md ```md -**Function**: `submitForm(formData)`\ **Inputs**: `formData: { key: string, value: any }`\ **Outputs**: `{ status: "success" | "error", message: string }` +**Function**: `handleApiResponse(response)`\ **Inputs**: `response: any`\ **Outputs**: `{ status: "success" | "error", data: any, message: string }` **Logic Flow** -1. Validate formData format -2. Save to IndexedDB or queue if offline -3. Return success/error +1. Check response for null/undefined +2. Retry on timeout +3. Log errors to `activity_log.md` **Dependencies** -- IndexedDB API -- FormData model +- API client library **Edge Cases** -- edge-001: Empty fields (Risk: 70) - - Mitigation: Check empty fields; return error - - Test: Empty/partial submissions -- edge-002: Offline submission (Risk: 80) - - Mitigation: Queue in IndexedDB; sync on reconnect - - Test: Simulate offline mode - -**Error Handling** - -- Return specific error messages -- Log with timestamps +- edge-004: Null response (Risk: 15) + - Mitigation: Return default value + - Test: Simulate null response +- edge-005: Timeout (Risk: 8) + - Mitigation: Retry request + - Test: Simulate timeout ``` ### tasks.md ```md -**task-001**: Implement submitForm +**task-003**: Handle null API response -- Depends: FormData model +- Depends: API client - Status: To Do -- Outcome: Validates/saves form data or queues offline -- Edge Cases: Empty fields, offline scenarios +- Outcome: Graceful error handling with default value +- Edge Cases: Null response, timeout - Priority: High - -**task-002**: Add form validation UI feedback - -- Depends: FormHandler -- Status: To Do -- Outcome: Show error messages for invalid inputs -- Edge Cases: Real-time validation for malformed inputs -- Priority: Medium ``` ### activity\_log.md @@ -202,21 +260,21 @@ You must follow a robust, interactive approach to software development. Clarify **Decision** - Date: 2025-07-23 -- Title: Use IndexedDB for offline storage -- Context: Persistent client-side data -- Options: IndexedDB, LocalStorage -- Rationale: IndexedDB handles larger data sets +- Title: Default value for null API response +- Context: Prevent crashes on null response +- Options: Throw error, return default +- Rationale: Default value ensures continuity - Status: Approved **Action** -- Date: 2025-07-23T14:00:00Z -- Action: Implement submitForm -- Outcome: Validates and saves form data -- Edge Cases: Empty fields, offline queuing -- Logs: 3 unit tests passed +- Date: 2025-07-23T15:00:00Z +- Action: Implement handleApiResponse +- Outcome: Handles null response with default +- Edge Cases: Null response, timeout +- Logs: 2 unit tests passed - Issues: None -- Next Steps: Offline sync testing +- Next Steps: Test timeout retry ``` ### steering/performance.tuning.md