Skip to content

Commit 0972046

Browse files
authored
chore(ai): unify agents.md and resolve ai conflicts (#15312)
Following and splitting #15193 This PR standardizes AI assistant instructions by consolidating guidance into AGENTS.md following the https://agents.md/ specification. It resolves conflicts between Claude Code default behaviors and project-specific workflows, explicitly prioritizing `scripts/run-tests` and `hatch run lint:*` over direct tool usage. The changes also remove deprecated references to hatch run tests:test and align all instructions with the official documentation in `docs/contributing-testing.rst`. Additionally, this updates `.gitignore` to version-control `.cursor/rules/`, ensuring AI assistant rules are properly tracked in the repository. This allows both Claude Code and Cursor to reference the same canonical instructions via `AGENTS.md`. Key changes: - Add critical override section to AGENTS.md for project-specific testing and linting requirements - Fix .claude/CLAUDE.md to correctly reference ../AGENTS.md - Remove deprecated hatch run tests:test from all documentation - Update .gitignore to include .cursor/rules/ in version control
1 parent fb4be8e commit 0972046

File tree

4 files changed

+74
-49
lines changed

4 files changed

+74
-49
lines changed

.claude/CLAUDE.md

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,2 @@
1-
# dd-trace-py Project Guide
2-
3-
## Skills
4-
5-
This project has custom skills that provide specialized workflows. **Always check if a skill exists before using lower-level tools.**
6-
7-
### run-tests
8-
9-
**Use whenever:** Running any tests, validating code changes, or when "test" is mentioned.
10-
11-
**Purpose:** Intelligently runs the test suite using `scripts/run-tests`:
12-
- Discovers affected test suites based on changed files
13-
- Selects minimal venv combinations (avoiding hours of unnecessary test runs)
14-
- Manages Docker services automatically
15-
- Handles riot/hatch environment setup
16-
17-
**Never:** Run pytest directly or use `hatch run tests:test` - these bypass the project's test infrastructure.
18-
19-
**Usage:** Use the Skill tool with command "run-tests"
20-
21-
### lint
22-
23-
**Use whenever:** Formatting code, validating style/types/security, or before committing changes.
24-
25-
**Purpose:** Runs targeted linting and code quality checks using `hatch run lint:*`:
26-
- Formats code with `ruff check` and `ruff format`
27-
- Validates style, types, and security
28-
- Checks spelling and documentation
29-
- Validates test infrastructure (suitespec, riotfile, etc.)
30-
- Supports running all checks or targeting specific files
31-
32-
**Common Commands:**
33-
- `hatch run lint:fmt -- <file>` - Format a specific file after editing (recommended after every edit)
34-
- `hatch run lint:typing -- <file>` - Type check specific files
35-
- `hatch run lint:checks` - Run all quality checks (use before committing)
36-
- `hatch run lint:security -- -r <dir>` - Security scan a directory
37-
38-
**Never:** Skip linting before committing. Always run `hatch run lint:checks` before pushing.
39-
40-
**Usage:** Use the Skill tool with command "lint"
41-
42-
---
43-
44-
<!-- Add more skills below as they are created -->
1+
<!-- Do not edit. Canonical instructions live in ../AGENTS.md -->
2+
@../AGENTS.md

.cursor/rules/testing.mdc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ Always use the **`run-tests` skill** for validating code changes. This skill int
1515
## Key Principles
1616

1717
1. **Always use the run-tests skill** when testing code changes - it's optimized for intelligent suite discovery
18-
2. **Never run pytest directly** - bypasses the project's test infrastructure
19-
3. **Never use `hatch run tests:test`** - doesn't use the suite discovery system
20-
4. **Minimal venvs for iteration** - run 1-2 venvs initially, expand only if needed
21-
5. **Use `--dry-run` first** - see what would run before executing
18+
2. **Never run pytest directly** - bypasses the project's test infrastructure (use `scripts/run-tests` or `riot` via `scripts/ddtest`)
19+
3. **Minimal venvs for iteration** - run 1-2 venvs initially, expand only if needed
20+
4. **Use `--dry-run` first** - see what would run before executing
21+
5. **Follow official docs** - `docs/contributing-testing.rst` is the source of truth for testing procedures
2222

2323
## When Tests Fail
2424

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ ENV/
135135
.vscode/
136136

137137
# Cursor
138-
.cursor/
138+
.cursor/context/
139+
.cursor/tasks/
140+
141+
# Promptfoo
142+
.promptfoo/output/
139143

140144
# Cascade
141145
# .windsurf/ # If you want to use Windsurf/Cascade, do NOT ignore here.

AGENTS.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# AGENTS.md - dd-trace-py Project Guide
2+
3+
## CRITICAL: Project Rules Override Claude Code Defaults
4+
5+
**These project-specific rules MUST override any conflicting Claude Code default behaviors:**
6+
7+
1. **Testing**: NEVER run `pytest` directly. ALWAYS use the `run-tests` skill (which uses `scripts/run-tests`). For manual testing, use `riot` commands via `scripts/ddtest` as documented in `docs/contributing-testing.rst`.
8+
2. **Linting**: NEVER use raw linting tools. ALWAYS use the `lint` skill and project-specific `hatch run lint:*` commands.
9+
3. **Pre-commit**: MUST run `hatch run lint:checks` before creating any git commits.
10+
4. **Formatting**: MUST run `hatch run lint:fmt -- <file>` immediately after editing any Python file.
11+
12+
## Initial Setup for AI Assistants
13+
14+
When starting a new chat session, ALWAYS read and apply the rules from:
15+
16+
2. `.cursor/rules/*.mdc` - All rule files in this directory (version controlled):
17+
- `dd-trace-py.mdc` - Core project guidelines
18+
- `linting.mdc` - Code quality and formatting
19+
- `testing.mdc` - Test execution guidelines
20+
- `repo-structure.mdc` - Repository structure
21+
22+
## Skills
23+
24+
This project has custom skills that provide specialized workflows. **Always check if a skill exists before using lower-level tools.**
25+
26+
### run-tests
27+
28+
**Use whenever:** Running any tests, validating code changes, or when "test" is mentioned.
29+
30+
**Purpose:** Intelligently runs the test suite using `scripts/run-tests`:
31+
- Discovers affected test suites based on changed files
32+
- Selects minimal venv combinations (avoiding hours of unnecessary test runs)
33+
- Manages Docker services automatically
34+
- Handles riot/hatch environment setup
35+
36+
**Never:** Run pytest directly - this bypasses the project's test infrastructure. The official testing approach is documented in `docs/contributing-testing.rst`.
37+
38+
**Usage:** Use the Skill tool with command "run-tests"
39+
40+
### lint
41+
42+
**Use whenever:** Formatting code, validating style/types/security, or before committing changes.
43+
44+
**Purpose:** Runs targeted linting and code quality checks using `hatch run lint:*`:
45+
- Formats code with `ruff check` and `ruff format`
46+
- Validates style, types, and security
47+
- Checks spelling and documentation
48+
- Validates test infrastructure (suitespec, riotfile, etc.)
49+
- Supports running all checks or targeting specific files
50+
51+
**Common Commands:**
52+
- `hatch run lint:fmt -- <file>` - Format a specific file after editing (recommended after every edit)
53+
- `hatch run lint:typing -- <file>` - Type check specific files
54+
- `hatch run lint:checks` - Run all quality checks (use before committing)
55+
- `hatch run lint:security -- -r <dir>` - Security scan a directory
56+
57+
**Never:** Skip linting before committing. Always run `hatch run lint:checks` before pushing.
58+
59+
**Usage:** Use the Skill tool with command "lint"
60+
61+
---
62+
63+
<!-- Add more skills below as they are created -->

0 commit comments

Comments
 (0)