tracelisted
Install: claude install-skill ApartsinProjects/PyTraceAutopsy
# PyTrace Autopsy
Trace Python function calls at runtime to debug failing tests. Uses `sys.settrace`
injected via `sitecustomize.py` through PYTHONPATH. No project files are modified.
## When to Use
- Tests fail and the cause is not obvious from reading the code
- You've attempted a fix but the test still fails
- You need to see what arguments a function actually received
- You need to see what a function actually returned vs what was expected
- An exception is being swallowed or raised from an unexpected location
## Phase 1: Detect Failing Tests
Run the failing test(s):
```bash
pytest <test_file_or_pattern> -x -v --tb=short 2>&1
```
If `$ARGUMENTS` is provided, use it as the test pattern.
Parse output to identify:
- Which test(s) failed and the assertion/exception
- The function under test (from the traceback)
- The source file and line number
If no tests fail, inform the user and stop.
## Phase 2: Analyze and Plan Trace Targets
1. Read the failing test code to understand what's being tested.
2. Read the function under test and its call chain.
3. Identify the project source root (look for `src/`, `lib/`, or the package directory).
4. Build trace targets:
- **paths**: Project source directories (NOT test dirs, NOT stdlib, NOT site-packages)
- **modules**: Specific modules if scope needs narrowing (optional)
- **functions**: Specific functions if only certain ones matter (optional)
5. Start with path-based filtering. Narrow later if trace output is too larg