agent-clean
Skill0 starsChanged 7 months agoMITView on GitHub
Purge tasks from an autonomous coding agent that failed due to infrastructure errors (rate limits, credit exhaustion, auth failures, network) — not code failures. Cleans the queue without losing legitimate failures that need triage.
- Sends data out
1 other project uses a version of this.
Adopted by
Most recently taken up by
- HermeticOrmus/ormus-agent-opsword for word, first seen Apr 25, 2026
Other versions1 project uses a version of this.
Word for word · 1
- HermeticOrmus/ormus-agent-ops★ 0100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- agent-evolveSkill
- agent-inspectSkill
- agent-opsSkill
- agent-statusSkill
- agent-sweep-orphansSkill
- agent-triageSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 88
After explicit user confirmation:
- Very specific: line 120
When in doubt: dead-letter is safer (reversible — you can re-create the task).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/agent-clean — Infrastructure-Failure Purge
Don't conflate "the agent didn't try because we ran out of credits" with "the agent tried and the code is broken."
The signal
Failed tasks in an autonomous agent fall into two completely different categories:
- Infra failures — agent never got a chance: rate limit, credit exhausted, network timeout, auth expired
- Real failures — agent tried, code is broken, prompt was wrong, env was missing
Bulk-requeuing all failures conflates these. Bulk-dead-lettering all failures throws away real work. /agent-clean separates them: it purges (or requeues) only the infra failures and leaves the real failures for /agent-triage.
Prerequisites
| Var | Purpose |
AGENT_API_URL | Base URL of the agent's HTTP API |
AGENT_API_TOKEN | Bearer token |
Usage
/agent-clean — sweep last 24h
/agent-clean 7d — sweep last 7 days
/agent-clean --requeue — requeue infra failures instead of dead-lettering
/agent-clean --dry-run — show what would be done, don't actWorkflow
Phase 1: Pull failures
curl -s -H "Authorization: Bearer $AGENT_API_TOKEN" \
"$AGENT_API_URL/api/tasks?status=failed&since=24h"Phase 2: Match each failure against infra patterns
For each failed task, fetch a tail of its log and match against these patterns:
| Pattern | Class |
rate.?limit / 429 Too Many Requests | rate-limit |
credit.?balance.?exhausted / insufficient.?(credits|balance) / quota.?exceeded | credit-exhausted |
401 Unauthorized / invalid.?api.?key / expired.?token | auth-expired |
ECONNRESET / ETIMEDOUT / getaddrinfo.?(ENOTFOUND|EAI_AGAIN) / socket hang up | network |
500 Internal Server Error / 502 Bad Gateway / 503 Service Unavailable (from upstream APIs) | upstream-5xx |
worker.?(died|killed|crashed) | worker-crash |
Anything that doesn't match — leave alone. That's a real failure that needs /agent-triage.
Phase 3: Group + present
INFRA SWEEP — <window>
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total failures: <N>
Infra failures: <N> ← this skill cleans these
Real failures: <N> ← use /agent-triage
INFRA BREAKDOWN
rate-limit: <N>
credit-exhausted: <N>
auth-expired: <N>
network: <N>
upstream-5xx: <N>
worker-crash: <N>
PROPOSED ACTION
default: dead-letter all infra failures (with reason logged)
--requeue mode: requeue all infra failures
Real failures NOT touched: <N> (run /agent-triage to handle these)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Confirm? [y/N]Phase 4: Execute
After explicit user confirmation:
# Default: dead-letter (cleaner — these were never the agent's fault, no need to retry)
for tid in $INFRA_TASK_IDS; do
curl -s -X POST -H "Authorization: Bearer $AGENT_API_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"reason\": \"infra: $CLASS\"}" \
"$AGENT_API_URL/api/tasks/$tid/dead-letter"
doneOr with --requeue:
for tid in $INFRA_TASK_IDS; do
curl -s -X POST -H "Authorization: Bearer $AGENT_API_TOKEN" \
"$AGENT_API_URL/api/tasks/$tid/requeue"
doneWhen to requeue vs dead-letter
| Scenario | Action |
| Rate limit hit, but you've upgraded the API tier | --requeue |
| Credits exhausted, you've topped up | --requeue |
| Auth expired, you've rotated tokens | --requeue |
| Generic network blip 3 days ago, work is no longer needed | dead-letter (default) |
| Worker crashed during a task that's no longer relevant | dead-letter |
| Upstream API was down briefly, work IS still needed | --requeue |
When in doubt: dead-letter is safer (reversible — you can re-create the task). --requeue only when you've fixed the root cause.
Pairs with
/agent-triage— handles the real failures (code, prompt, env). Run/agent-cleanfirst to remove noise, then/agent-triageon what remains./agent-status— verify the queue is clean afterward.
Notes
- Don't auto-requeue rate-limit failures while still rate-limited. You'll create another wave of failures. Verify the underlying constraint is fixed first.
- Log the reason on dead-letter. A future audit looking at "why was this dead-lettered" needs to see "infra: credit-exhausted" not just "dead-lettered."
- This skill is intentionally scoped narrowly. Don't try to clean code/prompt/env failures here — that's
/agent-triage's job. Keep the scope clean.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

