Debian Codegraph @

AGENTS.md

raw
1 # AGENTS.md
2
3 This file provides guidance to Claude Code (claude.ai/code) and other compatible agentic tools when working with code in this repository.
4
5 **Note:** This file is for AI assistant use only. For human developers, see the [Ansible Developer Guide](https://docs.ansible.com/ansible-core/devel/dev_guide/index.html).
6
7 ## ⚠️ IMPORTANT: Always Start Here
8
9 **BEFORE starting any PR review or development task:**
10
11 1. **Read this file first** - Don't work from memory or assumptions
12 2. **Read all [context](context) files** for the project's coding conventions and policies
13 3. **Use TodoWrite** to create a task list and track progress systematically
14 4. **Follow the numbered steps** in the relevant process sections
15 5. **Reference Quick Reference** for correct commands and patterns
16
17 ## ⚠️ CRITICAL: Licensing Requirements
18
19 **NEVER suggest, recommend, or approve code that violates the project's [licensing requirements](context/licensing.md).**
20 Always verify any new dependencies or suggested libraries are license-compatible.
21 This is non-negotiable -- licensing violations can create serious legal issues for the project.
22
23 ## General Principles
24
25 When reviewing code, don't flag issues that `ansible-test sanity` already catches.
26 Focus review effort on things automated checks can't verify.
27
28 ## Attribution
29
30 Agents should disclose their involvement in contributions.
31 We recommend using an `Assisted-by:` commit trailer identifying the AI tool that assisted.
32
33 ## Quick Reference
34
35 ```bash
36 # PR Review and CI
37 gh pr view <number> # Get PR details
38 gh pr view <number> --comments # Check for ansibot CI failures
39 gh pr checks <number> # Get Azure Pipelines URLs
40 gh pr checkout <number> # Switch to PR branch
41 gh pr diff <number> # See all changes
42 /azp-logs <number> # Download CI logs for PR
43 ```
44
45 **Critical Reminders:**
46
47 - **Licensing**: See [Licensing Requirements](context/licensing.md) - GPLv3/BSD-2-Clause only
48 - **Testing**: See [running-tests](context/running-tests.md) for `ansible-test` commands and container selection
49
50 ## Helping Developers with CI Failures
51
52 When developers submit PRs and encounter CI failures, use these approaches to help diagnose and resolve issues:
53
54 **1. Check for ansibot comments:**
55
56 ```bash
57 # Get all PR comments to find ansibot CI failure reports
58 gh pr view <number> --comments
59 ```
60
61 Look for comments from `ansibot` that contain:
62
63 - Test failure details with specific error messages
64 - File paths and line numbers for failures
65 - Links to sanity test documentation (e.g., `[explain](https://docs.ansible.com/...`)
66
67 **2. Get CI check status and URLs:**
68
69 ```bash
70 # See all CI check results with Azure Pipelines URLs
71 gh pr checks <number>
72 ```
73
74 This shows:
75
76 - Overall CI status (pass/fail) with timing
77 - Direct links to Azure DevOps build results
78 - Individual job results (Sanity Test 1/2, Docker tests, Units, etc.)
79
80 **3. CI failure analysis workflow:**
81
82 1. Check ansibot comments first for immediate error details
83 2. Use `gh pr checks <number>` to get Azure Pipelines URLs for detailed logs
84 3. Focus on failed jobs (marked as `fail`) and examine their specific error output
85 4. For sanity test failures, the error messages usually indicate exactly what needs to be fixed
86 5. For test failures, run the same tests locally using `ansible-test` to reproduce and debug
87
88 **4. Downloading Azure Pipelines logs for analysis:**
89
90 When CI failures need deeper investigation beyond what's visible in ansibot comments or the web UI, use the `/azp-logs` skill:
91
92 ```bash
93 # Download logs using PR number (automatically finds latest build)
94 /azp-logs <pr_number>
95
96 # Or use build ID directly from gh pr checks output
97 /azp-logs <build_id>
98
99 # Or use the full Azure Pipelines URL
100 /azp-logs https://dev.azure.com/ansible/ansible/_build/results?buildId=12345
101 ```
102
103 The skill uses `hacking/azp/download.py` to download console logs into a directory named after the build ID.
104
105 **After downloading, analyze the logs:**
106
107 - Grep for common failure patterns: `grep -r "FAILED\|ERROR\|Traceback" <build_id>/`
108 - Focus on logs from failed jobs identified in `gh pr checks` output
109 - Compare error messages with ansibot comments to get full context
110 - Sanity test failures usually have clear error messages with file:line references
111 - Integration/unit test failures may require examining full test output and tracebacks
112
113 **Advanced usage:**
114 The download script supports filtering and customization:
115
116 ```bash
117 # Download only logs matching specific job names
118 ./hacking/azp/download.py <build_id> --console-logs --match-job-name "Sanity.*"
119
120 # Download artifacts and metadata too
121 ./hacking/azp/download.py <build_id> --all
122 ```
123
124 See `.claude/skills/azp-logs/SKILL.md` for complete documentation.
125
126 ## PR Review Guidelines
127
128 ### PR Review Checklist
129
130 Use this checklist for EVERY PR review:
131
132 ```text
133 □ Created TodoWrite list for review steps
134 □ Step 1: Get PR details with gh pr view <number>
135 □ Step 2: Get PR diff with gh pr diff <number>
136 □ Step 3: Check required components (changelog, tests)
137 □ Step 4: Checkout PR branch with gh pr checkout <number>
138 □ Step 5: Review existing feedback with gh pr view <number> --comments
139 □ Step 6: Verify all issues addressed
140 □ Step 7: Call out any unresolved feedback
141 □ Mark each TodoWrite item as completed when done
142 ```
143
144 When assisting with PR reviews, verify:
145
146 - Changelog fragment exists (see [changelog requirements](context/documentation-standards.md#changelog-requirements))
147 - Appropriate tests are included (see [test expectations](context/writing-tests.md#test-expectations-for-pull-requests))
148
149 ### Review Process
150
151 Follow these steps in order for thorough PR reviews:
152
153 1. **Get PR details**: Use `gh pr view <number>` to understand the PR scope and description
154 2. **Get PR diff**: Use `gh pr diff <number>` to see all changes
155 3. **Check required components FIRST** (changelog and tests -- see links above)
156 4. **Checkout PR branch**: Use `gh pr checkout <number>` to examine code holistically with changes applied
157 5. **Review existing feedback**: Use `gh pr view <number> --comments` to see all comments and previous review feedback
158 6. **Verify all issues addressed**: Ensure all bot failures, reviewer requests, and discussion points are resolved
159 7. **Call out any unresolved review feedback**: Explicitly mention any discussions or requests that remain unaddressed
160
161 ### Review Task Management
162
163 - Use TodoWrite tool to track review steps for complex PRs
164 - Mark tasks as in_progress when actively working on them
165 - Complete tasks immediately after finishing each step
166 - This provides visibility to users about review progress
167
168 ### Review Tools
169
170 - `gh pr view <number>` - Get PR details and description
171 - `gh pr view <number> --comments` - See all comments and review feedback
172 - `gh pr diff <number>` - Get complete diff of changes
173 - `gh pr checkout <number>` - Switch to PR branch for holistic examination
174 - `Read` tool - Examine specific changed files in detail
175 - `Grep` tool - Search for related code patterns or test coverage (uses ripgrep/rg)