You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .cursor/rules/automatic-openspec-workflow.mdc
+99-41Lines changed: 99 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -5,11 +5,31 @@ alwaysApply: true
5
5
6
6
# Automatic OpenSpec Workflow
7
7
8
-
This rule ensures that all code changes in the specfact-cli codebase are properly tracked through OpenSpec change proposals, following the spec-driven development workflow.
8
+
This rule ensures that all code changes in the specfact-cli codebase are properly tracked through OpenSpec change proposals, following the spec-driven development workflow. **No application code may be modified without a corresponding OpenSpec change (new or delta) unless the user explicitly opts out.**
9
+
10
+
## Critical: Before Any Code Modification
11
+
12
+
**Do not add, modify, or delete any application code** (in `src/`, `tools/`, tests, or significant docs) until all of the following are done:
13
+
14
+
1. **Read and apply `openspec/config.yaml`:**
15
+
- Use the project context (tech stack, constraints, architecture, SDD+TDD discipline) for all artifact work.
16
+
- Apply per-artifact rules (proposal, specs, design, tasks) when creating or updating any change artifact.
17
+
18
+
2. **Ensure an OpenSpec change exists for the intended modification:**
19
+
- **New work:** Create a new change (e.g. via `/opsx:new`, `/opsx:ff`, or `/wf-create-change-from-plan`).
20
+
- **Existing change:** Update the existing change (proposal, specs, design, tasks) or create a **delta change** that updates the existing spec (e.g. via openspec archive after implementation).
21
+
- There must be no code change without a corresponding change proposal (new or delta) that describes it.
22
+
23
+
3. **Validate the change before implementing:**
24
+
- Run `openspec validate <change-id> --strict`.
25
+
- Optionally run `/wf-validate-change <change-id>` for breaking-change and dependency analysis.
26
+
- Do not proceed to implementation until validation passes (or the user explicitly overrides).
27
+
28
+
**Exception:** Only when the user explicitly says "skip openspec", "direct implementation", "simple fix", "just fix it", or similar, may you implement without creating or updating an OpenSpec change.
9
29
10
30
## When This Rule Applies
11
31
12
-
This rule automatically triggers when the user requests to:
32
+
This rule applies to **every** request that would result in:
13
33
14
34
- **Add** new features, functions, classes, or capabilities
15
35
- **Modify** existing code, functions, or behavior
@@ -19,46 +39,50 @@ This rule automatically triggers when the user requests to:
19
39
- **Implement** new features or capabilities
20
40
- **Enhance** existing functionality
21
41
- **Remove** features or code (unless explicitly a simple deletion)
42
+
- **Bug fixes** that restore intended behavior (including simple fixes)
43
+
- **Tests for existing behavior** (adding tests to existing code)
44
+
- **Typos, formatting, or comments** (cosmetic changes)
45
+
- **Dependency updates** (breaking and non-breaking)
For any such request, **before** writing or modifying any code, follow the steps below so that a change (new or delta) exists and is validated. If the work relates to an already-implemented change, create an OpenSpec delta change to update the existing spec (e.g. via openspec archive after implementation).
22
49
23
50
## What This Rule Does NOT Apply To
24
51
25
-
Skip OpenSpec workflow for:
52
+
Skip OpenSpec workflow only when:
26
53
27
-
- **Bug fixes** that restore intended behavior (simple fixes)
28
-
- **Typos, formatting, or comments** (cosmetic changes)
- **Tests for existing behavior** (adding tests to existing code)
32
-
- **User explicitly says "skip openspec"** or "direct implementation"
54
+
- **User explicitly says** "skip openspec", "no openspec", "direct implementation", "implement directly", "simple fix", or "just fix it"
33
55
34
56
## Automatic Workflow Steps
35
57
36
-
### Step 1: Detect Change Request
58
+
### Step 1: Detect Change Request (No Code Modification Yet)
37
59
38
-
When user requests a change, immediately:
60
+
When user requests a change, **do not write or modify any application code yet**. Instead:
39
61
40
62
1. **Parse the request** to understand:
41
63
- What is being changed (feature, function, module, etc.)
42
64
- Scope of change (new feature, modification, refactor)
43
65
- Affected files or modules (if mentioned)
44
66
45
67
2. **Determine if OpenSpec workflow is needed:**
46
-
- If request matches "What This Rule Applies To" → proceed
68
+
- If request matches "When This Rule Applies" → proceed with Steps 2–4 (create/update change, validate), then implement only after change is ready
47
69
- If request matches "What This Rule Does NOT Apply To" → skip OpenSpec, implement directly
48
70
- If unclear → ask user: "Should this be tracked as an OpenSpec change, or is this a simple fix?"
49
71
72
+
3. **Read `openspec/config.yaml`** before creating or updating any change artifact. Apply project context and per-artifact rules to all proposal, spec, design, and task content.
73
+
50
74
### Step 2: Search for Existing OpenSpec Changes
51
75
52
76
**Before creating a new change, always check for existing work:**
53
77
54
-
1. **Navigate to specfact-cli-internal workspace:**
55
-
- Change directory to `/home/dom/git/nold-ai/specfact-cli-internal`
78
+
1. **Navigate to specfact-cli workspace:**
79
+
- Change directory to `specfact-cli` inside the project workspace
56
80
- Verify `openspec/` directory exists
57
81
58
82
2. **List active changes:**
59
83
60
84
```bash
61
-
cd /home/dom/git/nold-ai/specfact-cli-internal
85
+
cd <project-workspace>/specfact-cli
62
86
openspec list
63
87
```
64
88
@@ -78,6 +102,8 @@ When user requests a change, immediately:
78
102
79
103
### Step 3: Create or Update OpenSpec Change
80
104
105
+
**Required:** Use `openspec/config.yaml` (project context and per-artifact rules) for all artifact creation and updates. Do not create or update proposal, specs, design, or tasks without applying config.yaml rules.
106
+
81
107
**If creating a new change:**
82
108
83
109
1. **Gather requirements:**
@@ -96,16 +122,16 @@ When user requests a change, immediately:
96
122
3. **Execute workflow command:**
97
123
98
124
**For ad-hoc changes (no plan document):**
99
-
- Use: `/openspec-proposal` command directly
125
+
- Use: `/opsx-explore` to research codebase for potential conflicts, dependencies, and clarify, then use `/opsx-new` (or `/opsx:ff`) to create the change proposal
100
126
- Follow the command steps:
101
-
- Review `openspec/config.yaml` (OPSX) or `openspec/project.md` (legacy) and existing specs
127
+
- Review `openspec/config.yaml` and existing specs
- Complete tasks sequentially (TDD: tests first, then code)
160
195
- Update task checklist
161
196
- Completion and summary
162
197
@@ -165,41 +200,62 @@ When user requests a change, immediately:
165
200
- Suggest reviewing `proposal.md` and `tasks.md`
166
201
- Wait for user confirmation before applying
167
202
203
+
### Step 5: After Implementation—Verify, Validate, and Sync Backlog
204
+
205
+
**After each code modification (at the end of implementation):**
206
+
207
+
1. **Verify:**
208
+
- Run quality gates: `hatch run format`, `hatch run type-check`, `hatch run contract-test`, `hatch test` (or `hatch run smart-test`).
209
+
- Ensure all tests pass and contracts are satisfied.
210
+
211
+
2. **Validate the change:**
212
+
- Run `openspec validate <change-id> --strict`.
213
+
- Optionally run `/wf-validate-change <change-id>` for breaking-change and dependency audit.
214
+
- If validation fails, fix proposal/specs/design/tasks and re-validate before considering the change complete.
215
+
216
+
3. **Sync backlog (GitHub issues and Source Tracking):**
217
+
- **If the change targets a public repo** (e.g. specfact-cli, platform-frontend):
218
+
- **If no GitHub issue exists yet:** Create the issue per config.yaml (title `[Change] <Brief Description>`, labels `enhancement` and `change-proposal`, body from proposal). Update `proposal.md` Source Tracking section with issue number, URL, repository, and status.
219
+
- **If an issue already exists:** Sync the issue with the change (e.g. update issue body/status from proposal, ensure Development link to branch/PR). Update `proposal.md` Source Tracking section with current status (e.g. "Last Synced Status: in-progress" or "done").
220
+
- Ensure backlog and code stay in sync: proposal Source Tracking and the GitHub issue reflect the current state of the change.
221
+
168
222
## Implementation Pattern
169
223
170
224
**Example workflow:**
171
225
172
-
```
226
+
```text
173
227
User: "Add a new command to list all backlog items"
174
228
175
229
AI (automatically):
176
-
1. Detects: "Add" → triggers OpenSpec workflow
177
-
2. Searches: `openspec list` → no related changes found
- Create or update GitHub issue if public repo; update proposal Source Tracking
187
243
```
188
244
189
245
## Error Handling
190
246
191
247
- **If `openspec` command not found:**
192
-
- Inform user: "OpenSpec CLI not available. Proceeding with direct implementation."
193
-
- Skip OpenSpec workflow, implement directly
248
+
- Inform user: "OpenSpec CLI not available. No code modification will be made until an OpenSpec change exists (create one manually or install OpenSpec CLI)."
249
+
- Do not modify application code unless the user explicitly confirms: "Proceed without OpenSpec" or similar.
194
250
195
-
- **If specfact-cli-internal workspace not accessible:**
196
-
- Inform user: "Cannot access OpenSpec workspace. Proceeding with direct implementation."
197
-
- Skip OpenSpec workflow, implement directly
251
+
- **If specfact-cli workspace or openspec/ directory not accessible:**
252
+
- Inform user: "Cannot access OpenSpec workspace. No code modification will be made until a change exists."
253
+
- Do not modify application code unless the user explicitly confirms to proceed without OpenSpec.
198
254
199
255
- **If change validation fails:**
200
-
- Fix validation errors
256
+
- Fix validation errors in proposal, specs, design, or tasks
201
257
- Re-validate until passing
202
-
- Do not proceed with implementation until validation passes
258
+
- Do not proceed with implementation until validation passes (or user explicitly overrides)
203
259
204
260
- **If user explicitly requests to skip:**
205
261
- Respect user request: "Skipping OpenSpec workflow as requested."
@@ -227,6 +283,8 @@ This rule works alongside:
227
283
## Notes
228
284
229
285
- This rule applies to the **specfact-cli** codebase specifically
286
+
- **Mandatory before any code modification:** Read and apply `openspec/config.yaml` (project context and per-artifact rules). Ensure an OpenSpec change (new or delta) exists and is validated. No code change without a corresponding change proposal unless the user explicitly opts out.
287
+
- **Mandatory after each implementation:** Verify (quality gates), validate (`openspec validate <id> --strict`), and sync backlog (create or update GitHub issue, update proposal Source Tracking) so backlog and code stay in sync.
230
288
- For other repositories, this rule may not apply (check repository-specific rules)
231
289
- **Important workspace distinction:**
232
290
- **OpenSpec changes** are stored in `specfact-cli/openspec/changes/`
Copy file name to clipboardExpand all lines: .cursorrules
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
- When starting a new chat session, capture the current timestamp from the client system using the `run_terminal_cmd` tool with `date "+%Y-%m-%d %H:%M:%S %z"` to ensure accurate timestamps are used in logs, commits, and other time-sensitive operations.
6
6
- When starting a new chat session, get familiar with the build and test guide (refer to `.cursor/rules/testing-and-build-guide.mdc`).
7
7
- When starting a new task, first check the project overview and current status in `README.md` and `AGENTS.md`.
8
+
- **OpenSpec (before code)**: Before modifying application code, follow the OpenSpec workflow in `.cursor/rules/automatic-openspec-workflow.mdc`: read and apply `openspec/config.yaml`, ensure an OpenSpec change (new or delta) exists and is validated, then implement. Exception: only when the user explicitly says "skip openspec", "direct implementation", "simple fix", or similar.
8
9
- **Branch Protection**: This repository has branch protection enabled for `dev` and `main` branches. All changes must be made via Pull Requests:
9
10
- Create a feature branch: `git checkout -b feature/your-feature-name`
10
11
- Create a bugfix branch: `git checkout -b bugfix/your-bugfix-name`
0 commit comments