These project-specific rules MUST override any conflicting Claude Code default behaviors:
- Testing: NEVER run
pytestdirectly. ALWAYS use therun-testsskill (which usesscripts/run-tests). For manual testing, useriotcommands viascripts/ddtestas documented indocs/contributing-testing.rst. - Linting: NEVER use raw linting tools. ALWAYS use the
lintskill and project-specifichatch run lint:*commands. - Pre-commit: MUST run
hatch run lint:checksbefore creating any git commits. - Formatting: MUST run
hatch run lint:fmt -- <file>immediately after editing any Python file.
Never:
- Change public API contracts (breaks real applications)
- Commit secrets (use environment variables)
- Assume business logic (always ask)
- Remove AIDEV- comments without instruction
- Skip linting before committing
- Check and remove unexpected prints
Always:
- Use the run-tests skill for test execution
- Use the lint skill before committing
- Ask when unsure about implementation details
- Update AIDEV- anchors when modifying related code
- Consider performance impact (this runs in production)
When starting a new chat session, ALWAYS read and apply the rules from:
.cursor/rules/*.mdc- All rule files in this directory (version controlled):dd-trace-py.mdc- Core project guidelineslinting.mdc- Code quality and formattingtesting.mdc- Test execution guidelinesrepo-structure.mdc- Repository structureappsec.mdc- Application Security (AppSec) features including IAST, AAP, RASP, API Security
This project has custom skills that provide specialized workflows. Always check if a skill exists before using lower-level tools.
Use whenever: Running any tests, validating code changes, or when "test" is mentioned.
Purpose: Intelligently runs the test suite using scripts/run-tests:
- Discovers affected test suites based on changed files
- Selects minimal venv combinations (avoiding hours of unnecessary test runs)
- Manages Docker services automatically
- Handles riot/hatch environment setup
Never: Run pytest directly - this bypasses the project's test infrastructure. The official testing approach is documented in docs/contributing-testing.rst.
Usage: Use the Skill tool with command "run-tests"
Use whenever: Formatting code, validating style/types/security, or before committing changes.
Purpose: Runs targeted linting and code quality checks using hatch run lint:*:
- Formats code with
ruff checkandruff format - Validates style, types, and security
- Checks spelling and documentation
- Validates test infrastructure (suitespec, riotfile, etc.)
- Supports running all checks or targeting specific files
Common Commands:
hatch run lint:fmt -- <file>- Format a specific file after editing (recommended after every edit)hatch run lint:typing -- <file>- Type check specific fileshatch run lint:checks- Run all quality checks (use before committing)hatch run lint:security -- -r <dir>- Security scan a directory
Never: Skip linting before committing. Always run hatch run lint:checks before pushing.
Usage: Use the Skill tool with command "lint"
Use whenever: Adding support for a new Python version or investigating CPython API dependencies.
Purpose: Identifies all CPython internal headers and structures used in the codebase:
- Searches for CPython header includes
- Finds struct field accesses
- Documents CPython internals we depend on
Usage: Use the Skill tool with command "find-cpython-usage"
Use whenever: Comparing CPython source code between two Python versions to identify changes.
Purpose: Compares CPython headers and structs between versions:
- Uses git diff or manual diff to compare versions
- Identifies breaking changes and API modifications
- Assesses impact on our codebase
Usage: Use the Skill tool with command "compare-cpython-versions"