specmem impact¶
Analyze the impact of code changes on specifications.
Usage¶
Description¶
Identifies which specifications and tests are affected by code changes using the impact graph.
Options¶
| Option | Description | Default |
|---|---|---|
--files, -f FILES |
Files to analyze | required* |
--git-diff |
Use git diff for changed files | false |
--git-staged |
Use git staged files | false |
--tests |
Include test recommendations | false |
--depth INT |
Traversal depth | 2 |
--format FORMAT |
Output format (text, json, list) | text |
--verbose, -v |
Show detailed output | false |
*One of --files, --git-diff, or --git-staged is required.
Examples¶
Analyze Specific Files¶
Output:
๐ Impact Analysis
Changed files:
โข src/auth/service.py
๐ฏ Directly Impacted Specs (2):
โข auth/requirements.md
โข auth/design.md
๐ Transitively Impacted (2):
โข api-security/design.md
โข session-management/tasks.md
Total: 4 specs impacted
Multiple Files¶
With Test Recommendations¶
Output:
๐ Impact Analysis
Changed files:
โข src/auth/service.py
๐ฏ Directly Impacted Specs (2):
โข auth/requirements.md
โข auth/design.md
๐งช Recommended Tests (4):
โข tests/test_auth.py::test_login
โข tests/test_auth.py::test_logout
โข tests/test_auth.py::test_token_refresh
โข tests/integration/test_auth_flow.py::test_full_flow
โฑ๏ธ Estimated time: 45s (vs 8m for full suite)
From Git Diff¶
From Staged Changes¶
Deeper Analysis¶
JSON Output¶
Output:
{
"changed_files": ["src/auth/service.py"],
"direct_specs": [
{
"path": "auth/requirements.md",
"relationship": "implemented_by"
}
],
"transitive_specs": [
{
"path": "api-security/design.md",
"relationship": "depends_on",
"via": "auth/requirements.md"
}
],
"recommended_tests": [
"tests/test_auth.py::test_login",
"tests/test_auth.py::test_logout"
]
}
List Output (for piping)¶
Output:
tests/test_auth.py::test_login
tests/test_auth.py::test_logout
tests/test_auth.py::test_token_refresh
Pipe to pytest¶
CI Integration¶
# GitHub Actions
- name: Get impacted tests
run: |
TESTS=$(specmem impact --git-diff --tests --format list)
if [ -n "$TESTS" ]; then
pytest $TESTS
fi