Skip to content

Commit 245d168

Browse files
authored
ci-cleaner: switch to Claude with max-turns, scope recompile, add exit guardrails (#24623)
1 parent 73887bf commit 245d168

File tree

3 files changed

+271
-121
lines changed

3 files changed

+271
-121
lines changed

.github/agents/ci-cleaner.agent.md

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,31 @@ make test-js
128128

129129
**Success criteria**: All JavaScript tests pass
130130

131-
### 5. Recompile All Workflows
131+
### 5. Recompile All Workflows (Only When Necessary)
132132

133-
Recompile all workflow markdown files to YAML lock files:
133+
`make recompile` regenerates ALL `.lock.yml` files. Running it when no `.md` workflow files changed produces 40–100 unchanged diffs and triggers an E003 "PR too large" error.
134+
135+
**Before running recompile**, check whether any workflow `.md` files were modified:
136+
137+
```bash
138+
git diff --name-only | grep '^\.github/workflows/.*\.md$'
139+
```
140+
141+
- **If the output is empty** (no workflow `.md` files changed) → **SKIP this step entirely**. Do not run `make recompile`.
142+
- **If workflow `.md` files are listed** → Run the recompile:
134143

135144
```bash
136145
make recompile
137146
```
138147

148+
After recompile, immediately verify the file count:
149+
150+
```bash
151+
git diff --name-only | wc -l
152+
```
153+
154+
**If more than 50 files changed**: This indicates a deeper issue (e.g., binary version mismatch or template changes). Do **not** create a PR with 50+ changed files. Call `noop` with: "Recompile generated {count} files (>50 limit). Possible cause: binary version mismatch / template changes. Manual investigation required."
155+
139156
This command:
140157
1. Syncs templates from `.github` to `pkg/cli/templates`
141158
2. Rebuilds the `gh-aw` binary
@@ -148,7 +165,7 @@ This command:
148165
3. Fix issues in the workflow frontmatter or content
149166
4. Re-run `make recompile`
150167

151-
**Success criteria**: All workflows compile successfully without errors
168+
**Success criteria**: All workflows compile successfully without errors; total changed file count ≤ 50
152169

153170
## Mandatory Exit Protocol
154171

@@ -170,6 +187,16 @@ This command:
170187

171188
This is a strict requirement — **every session must produce a safe output**.
172189

190+
## ⚠️ ABSOLUTE FINAL RULE (cannot be skipped)
191+
192+
Before your response ends — no matter what happened — you MUST call one of:
193+
- `create_pull_request` if you changed any files
194+
- `noop` if you changed nothing
195+
196+
**If you are about to end your response without having called a safe-output tool, call `noop` RIGHT NOW** with whatever message describes the situation.
197+
198+
There are no exceptions to this rule.
199+
173200
## Workflow & Best Practices
174201

175202
### Execution Order
@@ -191,6 +218,18 @@ When fixing issues:
191218
3. **Verify the fix** before moving to the next issue
192219
4. **Commit progress** after completing each major step
193220

221+
### File-Count Guard Before PR Creation
222+
223+
Before committing and calling `create_pull_request`, **always** verify how many files you are about to include:
224+
225+
```bash
226+
git add -A
227+
git diff --cached --name-only | wc -l
228+
```
229+
230+
- **If the count is ≤ 80**: Proceed normally with `git commit` and `create_pull_request`.
231+
- **If the count is > 80**: Too many files — this will exceed the PR size limit. Call `noop` with an explanation of what caused the large diff instead of creating an oversized PR.
232+
194233
### Common Issues
195234

196235
#### Go Linting Issues
@@ -227,30 +266,20 @@ The repository uses a Makefile for all build/test/lint operations. Key commands:
227266
- `make test` - Run all Go tests including integration (~30s)
228267
- `make test-js` - Run JavaScript tests
229268
- `make test-all` - Run both Go and JavaScript tests
230-
- `make recompile` - Recompile all workflows
231-
- `make agent-finish` - Run complete validation (use this for final check)
269+
- `make recompile` - Recompile all workflows (only if .md files changed)
270+
- `make agent-finish` - Run complete validation (avoid — takes 10–15 min)
271+
272+
**⚠️ Do NOT run `make deps-dev` or `make agent-finish`** — deps are already installed by the workflow setup steps, and `make agent-finish` takes 10–15 minutes. Only run targeted commands (`make fmt`, `make lint`, `make test-unit`, `make recompile` (only if .md files changed)) as needed.
232273

233274
### Final Validation
234275

235-
Before completing your work, optionally run the full validation suite:
276+
Only run targeted validations, not the full suite:
236277

237278
```bash
238-
make agent-finish
279+
make fmt && make lint && make test-unit
239280
```
240281

241-
**WARNING**: This command takes ~10-15 minutes and runs:
242-
- `make deps-dev` - Install dev dependencies
243-
- `make fmt` - Format code
244-
- `make lint` - Run linters
245-
- `make build` - Build binary
246-
- `make test-all` - Run all tests
247-
- `make recompile` - Recompile workflows
248-
- `make dependabot` - Generate Dependabot manifests
249-
- `make generate-schema-docs` - Generate schema documentation
250-
- `make generate-agent-factory` - Generate agent factory documentation
251-
- `make security-scan` - Run security scans
252-
253-
Only run this if explicitly requested or for final verification.
282+
**Avoid `make agent-finish`** — it takes 10–15 minutes and re-installs dev dependencies that are already present.
254283

255284
## Response Style
256285

0 commit comments

Comments
 (0)