luum-home/luum-cognitive-os/auto-refine
- community
Checking that the SKILL.md file is still in the repository.
Analyze a failed agent's output, determine root cause, and re-launch
Install
npx vskill@latest install luum-home/luum-cognitive-os/auto-refineSKILL.md
Auto-Refine Skill
Closes the PITER loop by analyzing agent failures and re-launching with corrective context.
When to Use
- When an agent task fails and the
auto-refine.shhook signalsORCHESTRATOR ACTION REQUIRED - Manually via
/auto-refinewhen you want to retry a failed agent with better instructions - After the orchestrator receives an escalation and the human approves a retry
Instructions
Step 1: Identify the Failed Task
Locate the failure context from one of these sources (in priority order):
- Hook output: If
auto-refine.shjust fired, the retry context is in the hook's stdout - active-tasks.json: Check
.cognitive-os/tasks/active-tasks.jsonfor tasks withstatus: "failed" - Engram: Search for recent agent failures via
mem_search(query: "agent failed", project: "{project}") - User-provided: The user may paste the error output directly
Extract:
- Original task description: What the agent was supposed to do
- Failure type: TEST_FAILURE, BUILD_ERROR, LINT_ERROR, COVERAGE_FAILURE, AGENT_ERROR
- Error details: The specific error messages
- Attempt number: Which retry this is (1, 2, or 3)
- Previous attempts: What was tried before (if available from history file)
Step 2: Analyze the Failure
Determine the root cause category:
| Category | Signal | Refinement Strategy | |
|---|---|---|---|
| Code bug | Test assertion fails, wrong output | Fix the logic, not the test | |
| Missing import/dep | Module not found, cannot resolve | Add dependency, fix import path | |
| Type error | TS/Go type mismatch | Fix type annotations or casting | |
| Architecture violation | Wrong layer, wrong pattern | Restructure per architecture rules | |
| Test infrastructure | Connection refused, timeout | Check infra is running, add mocks | |
| Scope issue | Error in unrelated code | Narrow scope, don't touch unrelated files | |
| Flaky test | Passes sometimes | Add retries, fix race conditions |
Step 3: Build Refined Instructions
Construct a new agent prompt that includes:
Step 4: Re-Launch the Agent
Delegate the refined task to a sub-agent with the constructed prompt.
Include:
- The original skill reference (if the original agent used a skill)
- Phase context from
cognitive-os.yaml - Error pattern warnings from
error-pattern-detector.sh(if applicable)
Step 5: Track the Refinement
After the re-launched agent completes:
- If success:
- Log to Engram:
mem_save(title: "Auto-refined: {task}", type: "bugfix", content: ...) - Clean up retry files in
.cognitive-os/metrics/auto-refine/
- If failure (attempt < 3):
- The
auto-refine.shhook will fire again automatically - The orchestrator loops back to Step 1
- If failure (attempt = 3):
- The hook will output an ESCALATION
- Report to the human with full attempt history
- Include: all 3 attempts, all errors, your root cause hypothesis, recommended human action
Refinement History
Retry tracking files are stored in .cognitive-os/metrics/auto-refine/:
{fingerprint}.count— Current retry count (0-3){fingerprint}.history— JSONL of each attempt with type, timestamp, details
These are automatically cleaned up on success or after escalation.
Phase-Aware Behavior
| Phase | Auto-Refine Behavior | |
|---|---|---|
| reconstruction | Always auto-retry. Agents fix their own work. | |
| stabilization | Always auto-retry. Agents fix their own work. | |
| production | Detect failure, suggest retry, but require human approval before re-launch. | |
| maintenance | Detect failure, suggest retry, but require human approval before re-launch. |
Anti-Patterns
- Do NOT retry with the exact same instructions (definition of insanity)
- Do NOT increase scope on retry (fix the original task, don't add features)
- Do NOT skip verification on the final attempt ("it should work now")
- Do NOT auto-refine tasks that failed due to missing infrastructure (fix infra first)
- Do NOT retry if the error is in code the agent didn't write (escalate instead)
Engram Integration
After a successful auto-refinement, save the learning:
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingpackages/sdd-compound/skills/auto-refine/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/luum-home/luum-cognitive-os/auto-refine)