@@ -6,6 +6,19 @@ alwaysApply: true
66
77# Workflow Rules for Bug Fixes and New Features
88
9+ ## Mandatory Flow (Use Always)
10+
11+ For **new features** follow this order strictly. Do not skip steps.
12+
13+ 1. **Plan** - write what to do for the new feature
14+ 2. **Tests (red)** - write tests for the feature, run them, ensure they fail
15+ 3. **Code** - implement the feature
16+ 4. **Tests (green)** - run the new tests, ensure they pass
17+ 5. **All tests** - run full test suite, ensure everything passes
18+ 6. **Documentation** - write docs and examples if needed
19+ 7. **Linter** - run linter, fix all issues
20+ 8. **Report** - write what was done
21+
922## Virtual Environment
1023
1124**IMPORTANT**: Virtual environment is located in `.venv` directory. Always activate it before running tests or commands:
@@ -34,146 +47,126 @@ source .venv/Scripts/activate
3447
3548### Mandatory Workflow for New Features
3649
37- **CRITICALLY IMPORTANT**: When user asks to implement a new feature (using words "фича", "feature", "новая функция", "добавить", "implement", "add"), **always** apply TDD approach and follow this strict workflow:
50+ **CRITICALLY IMPORTANT**: When user asks to implement a new feature (using words "фича", "feature", "новая функция", "добавить", "implement", "add"), **always** use the flow from "Mandatory Flow" above.
3851
39- **Do not skip any step!** Always follow order: write test (red) → verify test fails → implement feature → test (green) → run all tests → run linter → update documentation → report.
52+ **Do not skip any step!** Order: plan → tests (red) → code → tests (green) → all tests → documentation → linter → report.
4053
4154### Step-by-step Process for New Features
4255
43- 1. **Write test first**
44- - Create test in corresponding file `tests/test_*.py`
45- - Test must **fail** (red) because feature doesn't exist yet
46- - Test must clearly describe expected behavior
47- - Make sure test actually fails for the right reason
48- - Run test:
49- - **Linux/macOS**: `source .venv/bin/activate && pytest tests/test_*.py::test_name -v`
50- - **Windows**: `.venv\Scripts\activate && pytest tests/test_*.py::test_name -v`
56+ 1. **Plan**
57+ - Write what to do for the new feature (scope, steps, files to touch)
58+ - Clarify expected behavior and edge cases
59+ - Fix the order of work before writing code or tests
5160
52- 2. **Verify test fails**
53- - Run new test:
61+ 2. **Write tests and verify they fail (red)**
62+ - Create tests in corresponding file `tests/test_*.py`
63+ - Tests must **fail** (red) because feature does not exist yet
64+ - Tests must clearly describe expected behavior
65+ - Run tests and ensure they fail for the right reason:
5466 - **Linux/macOS**: `source .venv/bin/activate && pytest tests/test_*.py::test_name -v`
5567 - **Windows**: `.venv\Scripts\activate && pytest tests/test_*.py::test_name -v`
56- - Test must **fail** (red) - this confirms test is correct
57- - If test passes unexpectedly, review test logic
68+ - If tests pass unexpectedly, review test logic
5869
59- 3. **Implement feature**
60- - Write code that implements new feature
70+ 3. **Implement feature (code) **
71+ - Write code that implements the new feature
6172 - Follow rules from @code-style.mdc and @architecture.mdc
6273 - Use @implementation-order.mdc if adding new classes
6374 - Implement one class/module at a time
6475
65- 4. **Verify feature works **
66- - Run new test :
76+ 4. **Run new tests and verify they pass (green) **
77+ - Run the new tests :
6778 - **Linux/macOS**: `source .venv/bin/activate && pytest tests/test_*.py::test_name -v`
6879 - **Windows**: `.venv\Scripts\activate && pytest tests/test_*.py::test_name -v`
69- - Test must **pass** (green)
70- - Make sure feature works as expected
80+ - Tests must **pass** (green)
81+ - Ensure feature behaves as expected
7182
72835. **Run all tests**
7384 - Execute full test suite:
7485 - **Linux/macOS**: `source .venv/bin/activate && pytest tests/ -v`
7586 - **Windows**: `.venv\Scripts\activate && pytest tests/ -v`
76- - Make sure **all tests are green**
77- - If there are failing tests - fix them before proceeding
87+ - **All tests must be green**
88+ - If any fail, fix them before proceeding
7889
79- 6. **Run linter**
90+ 6. **Documentation and examples (optional)**
91+ - Update or add documentation for the new feature if necessary
92+ - Add examples if needed
93+ - Update API docs if needed
94+ - Keep docs clear and complete
95+
96+ 7. **Run linter**
8097 - Execute linter:
8198 - **Linux/macOS**: `source .venv/bin/activate && pre-commit run -a`
8299 - **Windows**: `.venv\Scripts\activate && pre-commit run -a`
83- - Fix all linting errors
84- - Make sure linter passes completely
85- - If there are errors, fix them and repeat step 6
86-
87- 7. **Update documentation**
88- - Update relevant documentation files to describe the new feature
89- - Add examples if applicable
90- - Update API documentation if needed
91- - Ensure documentation is clear and complete
92-
93- 8. **Write report**
94- - Brief report of work done
95- - What feature was implemented
96- - Which tests were added/changed
97- - Test run results
98- - Linter results
99- - Documentation updates
100+ - Fix all lint issues; repeat until linter passes
101+
102+ 8. **Report**
103+ - Short summary of what was done
104+ - What was implemented, which tests added/changed
105+ - Test and linter results
106+ - Documentation changes
100107
101108### Report Structure Example for New Features
102109
103110```markdown
104111## Feature: [brief description]
105112
106113### Implementation
107- 1. Added test `test_new_feature` in `tests/test_module.py` (initially red)
108- 2. Implemented `new_method` in `sgr_agent_core/module.py`
109- 3. Ran new test - passed (green)
110- 4. Ran all tests - all green (239 passed)
111- 5. Ran linter - all checks passed
112- 6. Updated documentation in `docs/*/framework/feature.md`
114+ 1. Plan: [what was planned - scope, steps]
115+ 2. Added tests in `tests/test_module.py` (initially red), verified they fail
116+ 3. Implemented `new_method` in `sgr_agent_core/module.py`
117+ 4. Ran new tests - passed (green)
118+ 5. Ran all tests - all green (239 passed)
119+ 6. Updated documentation in `docs/*/framework/feature.md`, added example if needed
120+ 7. Ran linter - all checks passed
121+ 8. Report: what was done (this block)
113122
114123### Changed Files
115124- `sgr_agent_core/module.py` - added new_method implementation
116- - `tests/test_module.py` - added test_new_feature test
125+ - `tests/test_module.py` - added tests for new feature
117126- `docs/*/framework/feature.md` - added documentation for new feature
118127```
119128
120129## Bug Fixes (TDD Approach)
121130
122131### Mandatory Workflow for Bug Fixes
123132
124- **CRITICALLY IMPORTANT**: When user asks to fix a bug (using words "баг", "bug", "ошибка", "error", "исправить", "fix"), **always** apply TDD approach and follow this strict workflow:
133+ **CRITICALLY IMPORTANT**: When fixing a bug, use the same flow as for features. Order: plan → tests (red) → code → tests (green) → all tests → documentation → linter → report.
125134
126- **Do not skip any step!** Always follow order: test (red) → fix → test (green) → all tests → run linter → update documentation → report.
135+ **Do not skip any step!**
127136
128137### Step-by-step Process for Bug Fixes
129138
130- 1. **Write test reproducing bug**
131- - Create test in corresponding file `tests/test_*.py`
132- - Test must **fail** (red) and reproduce bug
133- - Make sure error actually exists
134- - Run test:
139+ 1. **Plan**
140+ - Define what is broken and where to fix it (scope, cause, files to change)
141+
142+ 2. **Write test reproducing bug and verify it fails (red)**
143+ - Create test in `tests/test_*.py` that reproduces the bug
144+ - Test must **fail** (red)
145+ - Run test and ensure it fails for the right reason:
135146 - **Linux/macOS**: `source .venv/bin/activate && pytest tests/test_*.py::test_name -v`
136147 - **Windows**: `.venv\Scripts\activate && pytest tests/test_*.py::test_name -v`
137148
138- 2 . **Fix code**
139- - Write code that fixes bug
140- - Follow rules from @code-style.mdc and @architecture.mdc
141- - Make minimal changes needed to fix the bug
149+ 3 . **Fix code**
150+ - Implement the fix
151+ - Follow @code-style.mdc and @architecture.mdc
152+ - Change only what is needed to fix the bug
142153
143- 3. **Verify fix**
144- - Run new test:
145- - **Linux/macOS**: `source .venv/bin/activate && pytest tests/test_*.py::test_name -v`
146- - **Windows**: `.venv\Scripts\activate && pytest tests/test_*.py::test_name -v`
147- - Test must **pass** (green)
148- - Make sure bug is fixed
154+ 4. **Run new test and verify it passes (green)**
155+ - Run the new test - it must **pass** (green)
156+ - Confirm the bug is fixed
149157
150- 4. **Run all tests**
151- - Execute full run:
152- - **Linux/macOS**: `source .venv/bin/activate && pytest tests/ -v`
153- - **Windows**: `.venv\Scripts\activate && pytest tests/ -v`
154- - Make sure **all tests are green**
155- - If there are failing tests - fix them
158+ 5. **Run all tests**
159+ - Run full suite: `pytest tests/ -v`
160+ - **All tests must be green**
156161
157- 5. **Run linter**
158- - Execute linter:
159- - **Linux/macOS**: `source .venv/bin/activate && pre-commit run -a`
160- - **Windows**: `.venv\Scripts\activate && pre-commit run -a`
161- - Fix all linting errors
162- - Make sure linter passes completely
163- - If there are errors, fix them and repeat step 5
164-
165- 6. **Update documentation**
166- - Update relevant documentation files to describe the bug fix
167- - Add examples if applicable
168- - Update API documentation if needed
169- - Ensure documentation reflects the fix
170-
171- 7. **Write report**
172- - Brief report of work done
173- - What was fixed
174- - Which tests were added/changed
175- - Test run results
176- - Linter results
162+ 6. **Documentation**
163+ - Update docs to reflect the fix, add examples if needed
164+
165+ 7. **Run linter**
166+ - `pre-commit run -a`, fix all issues until clean
167+
168+ 8. **Report**
169+ - What was fixed, which tests added/changed, test and linter results
177170
178171### Report Structure Example for Bug Fixes
179172
@@ -184,12 +177,14 @@ source .venv/Scripts/activate
184177[Bug description]
185178
186179### Solution
187- 1. Added test `test_bug_reproduction` in `tests/test_module.py` (initially red)
188- 2. Fixed method `method_name` in `sgr_agent_core/module.py`
189- 3. Ran new test - passed (green)
190- 4. Ran all tests - all green (239 passed)
191- 5. Ran linter - all checks passed
192- 6. Updated documentation in `docs/en/framework/module.md` to reflect the fix
180+ 1. Plan: [what was broken, where to fix]
181+ 2. Added test in `tests/test_module.py` (red), verified it fails
182+ 3. Fixed `method_name` in `sgr_agent_core/module.py`
183+ 4. Ran new test - passed (green)
184+ 5. Ran all tests - all green
185+ 6. Updated documentation in `docs/en/framework/module.md`
186+ 7. Ran linter - all checks passed
187+ 8. Report: what was done (this block)
193188
194189### Changed Files
195190- `sgr_agent_core/module.py` - fixed processing logic
@@ -199,25 +194,12 @@ source .venv/Scripts/activate
199194
200195## Final Verification Before Reporting
201196
202- **MANDATORY**: Before writing final report for any work (bug fix or new feature), **always** complete these steps:
203-
204- 1. **Run all tests**:
205- - **Linux/macOS**: `source .venv/bin/activate && pytest tests/ -v`
206- - **Windows**: `.venv\Scripts\activate && pytest tests/ -v`
207- - All tests must pass (green)
208- - No test failures allowed
209-
210- 2. **Run linter**:
211- - **Linux/macOS**: `source .venv/bin/activate && pre-commit run -a`
212- - **Windows**: `.venv\Scripts\activate && pre-commit run -a`
213- - All linting checks must pass
214- - Fix all errors and warnings
215- - Repeat until all checks pass
216-
217- 3. **Only then write report**
218- - Report must include test results
219- - Report must include linter results
220- - Report must confirm all checks passed
197+ **MANDATORY**: Before writing the final report for any work (bug fix or new feature), complete the full flow. The last steps must be in this order:
198+
199+ 1. **All tests pass** - `pytest tests/ -v`, no failures
200+ 2. **Documentation updated** - docs and examples (if needed) are done
201+ 3. **Linter passes** - `pre-commit run -a`, all checks green
202+ 4. **Then write report** - include what was done, test results, linter results
221203
222204## Testing Commands Reference
223205
0 commit comments