A structured workflow for implementing code changes with quality built in. Covers the full cycle from understanding the codebase to having a verified, reviewable diff.
Use cases: Bug fixes, feature development, refactoring, open-source contributions, any code change that needs to be correct and maintainable.
Never write code before understanding the context. This phase prevents wasted effort and bad designs.
Check for and read these files (if they exist):
CONTRIBUTING.md — contribution guidelines.editorconfig — formatting rulespyproject.toml / package.json / Makefile — project config, linting, formattingtox.ini / .flake8 / .eslintrc — code style rulestests/, __tests__/, test/test_feature.py, feature.test.ts, feature_test.goBefore writing code, articulate:
snake_case, don't introduce camelCaseFix verification — prove the bug is fixed / feature works text
test_feature_handles_null_input() # The exact scenario from the issue
Edge cases — boundary conditions text
test_feature_with_empty_string()
test_feature_with_max_length_input()
test_feature_with_special_characters()
Error handling — invalid inputs, failure paths text
test_feature_raises_on_invalid_type()
test_feature_returns_none_on_missing_key()
Regression — existing behavior preserved text
test_existing_behavior_unchanged()
test_other_module_still_works()
One assertion per test (ideally) — makes failures easy to diagnose
Descriptive names — test_oauth_token_refreshes_when_expired not test_token
Arrange-Act-Assert pattern: python
def test_feature():
# Arrange
input_data = create_test_data()
# Act
result = feature(input_data)
# Assert
assert result.status == "success"
Use fixtures for reusable setup
Mock external dependencies — network calls, file system, databases
Test behavior, not implementation — don't assert on internal state
bash
# 1. Run only your new/modified tests first (fast feedback)
python -m pytest tests/test_my_feature.py -v --tb=short
# or: npm test -- --testPathPattern=my_feature
# or: go test ./pkg/my_feature/... -v
# 2. Run the full test module/directory
python -m pytest tests/ -v --tb=short
# 3. Run the entire test suite (before committing)
python -m pytest --tb=short
# or: npm test
# or: go test ./...
ScenarioActionAll pass ✅Proceed to diff reviewYour tests failFix the code, re-runPre-existing failuresNote them, don't fix (out of scope)Flaky tests (pass/fail randomly)Run 3x to confirm flakiness, note in PRTests you can't run (need env/infra)Note in PR, explain what you tested manually
Before committing, review every line of your diff.
bash
# Overview of what changed
git diff --stat
# Full diff
git diff
# If already staged
git diff --cached
bash
# Stage specific files (never use `git add .`)
git add path/to/modified_file.py
git add tests/test_new_feature.py
# Verify staged files
git diff --cached --stat
# Commit with conventional message
git commit -m "fix(module): short description of what was fixed
Longer explanation of why, if non-obvious.
Addresses #issue_number"
text
{type}({scope}): {concise description}
{body: what and why, not how}
{footer: issue refs, test results, breaking changes}
TypeWhenfixBug fixfeatNew featurerefactorCode restructure (no behavior change)testAdding/fixing tests onlydocsDocumentation changes onlychoreBuild/tooling/dependency changes