dev-test
by @sliverp
Structured development and testing SOP for implementing code changes. Covers codebase study, minimal focused implementation, test writing patterns, test exec...
clawhub install dev-testπ About This Skill
name: dev-test description: "Structured development and testing SOP for implementing code changes. Covers codebase study, minimal focused implementation, test writing patterns, test execution, and diff review. Applies to any development work β bug fixes, features, refactors, or open-source contributions. Use when you need a disciplined development workflow with built-in quality checks."
Dev Test β Development & Testing SOP
Overview
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.
Workflow
Phase 1: Study Before Coding
Never write code before understanding the context. This phase prevents wasted effort and bad designs.
#### 1a. Understand the project conventions
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 rules#### 1b. Study the area of change
#### 1c. Study existing tests
tests/, __tests__/, test/test_feature.py, feature.test.ts, feature_test.go#### 1d. Draft a mental model
Before writing code, articulate:
Phase 2: Implement
#### Core principles
1. Minimal, focused changes - Fix the bug / add the feature. Nothing else. - Avoid unrelated formatting changes, import reordering, or drive-by refactors. - If you spot something else to fix, note it for a separate commit/PR.
2. Follow existing patterns
- Match the codebase's style, not your preferred style
- Use the same naming conventions, indentation, comment style
- If the project uses snake_case, don't introduce camelCase
3. Add comments for non-obvious logic - "Why" comments, not "what" comments - Explain trade-offs, workarounds, and intentional decisions
4. Design for quality
| Principle | Meaning | Example | |-----------|---------|---------| | Defense-in-depth | Layer multiple protections | Validate input at API + service + DB layer | | Backward compatibility | Don't break existing behavior | Add new params with defaults | | Graceful degradation | Handle missing features | Platform-specific code falls back safely | | Extensibility | Prefer composable designs | Plugin/middleware over hardcoded switch | | Single responsibility | One function = one job | Extract logic instead of growing functions |
Phase 3: Write Tests
#### Test categories (implement in order)
1. Fix verification β prove the bug is fixed / feature works
test_feature_handles_null_input() # The exact scenario from the issue
2. Edge cases β boundary conditions
test_feature_with_empty_string()
test_feature_with_max_length_input()
test_feature_with_special_characters()
3. Error handling β invalid inputs, failure paths
test_feature_raises_on_invalid_type()
test_feature_returns_none_on_missing_key()
4. Regression β existing behavior preserved
test_existing_behavior_unchanged()
test_other_module_still_works()
#### Test writing guidelines
test_oauth_token_refreshes_when_expired not test_token def test_feature():
# Arrange
input_data = create_test_data() # Act
result = feature(input_data)
# Assert
assert result.status == "success"
Phase 4: Run Tests
#### Progressive testing strategy
# 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=short3. Run the entire test suite (before committing)
python -m pytest --tb=short
or: npm test
or: go test ./...
#### Handling test results
| Scenario | Action | |----------|--------| | All pass β | Proceed to diff review | | Your tests fail | Fix the code, re-run | | Pre-existing failures | Note them, don't fix (out of scope) | | Flaky tests (pass/fail randomly) | Run 3x to confirm flakiness, note in PR | | Tests you can't run (need env/infra) | Note in PR, explain what you tested manually |
Phase 5: Review the Diff
Before committing, review every line of your diff.
# Overview of what changed
git diff --statFull diff
git diffIf already staged
git diff --cached
#### Diff review checklist
Phase 6: Commit
# Stage specific files (never use git add .)
git add path/to/modified_file.py
git add tests/test_new_feature.pyVerify staged files
git diff --cached --statCommit with conventional message
git commit -m "fix(module): short description of what was fixedLonger explanation of why, if non-obvious.
Addresses #issue_number"
#### Commit message format
{type}({scope}): {concise description}{body: what and why, not how}
{footer: issue refs, test results, breaking changes}
| Type | When |
|------|------|
| fix | Bug fix |
| feat | New feature |
| refactor | Code restructure (no behavior change) |
| test | Adding/fixing tests only |
| docs | Documentation changes only |
| chore | Build/tooling/dependency changes |