Refine

SkillAI & models

Refine is a skill that lets an agent schedule updates to its own harness, meaning its prompts, memories, skills, and subagent specs. It is called from the Python REPL with refine.run, which returns immediately and queues the refinement to run when the current turn ends. It is meant for persisting repeated failures, reusable tactics, delegation roles, or behavior policies rather than rewriting the whole harness.

Then ask your AI: use the Refine skill

Details

Instructions available. Your AI can read the instructions. Execution depends on the setup they require.

Have an agent environment with a Python REPL and the refine skill available.

What your AI can do with it

  • Schedule harness refinement with await refine.run() from the Python REPL
  • Focus a refinement on a specific observation by passing instructions
  • Target the global harness store for cross-session changes with global_=True
  • Check pending and in_flight refine state with await refine.status()
  • Apply small, evidence-backed updates to prompts, memories, skills, and subagent specs
  • Rebuild the system prompt and resume work after refinement completes

Getting started

  1. Have an agent environment with a Python REPL and the refine skill available.
  2. Call await refine.status() to see whether a refine is already pending or in flight.
  3. Call await refine.run() to schedule refinement, optionally passing instructions to focus it.
  4. Pass global_=True when the change should go to the global harness store instead of the session.
  5. Continue working normally; the refinement runs when the current turn ends.

What this skill tells your AI

The instructions your AI receives, as published by primeintellect-ai/prime-agent in skills/refine/SKILL.md and read by Ahel’s review.

Refinement analyzes the conversation trajectory and applies small, evidence-backed updates to the continual harness (prompts, memories, skills, subagent specs). The implementation lives in the host (the same one behind the user's /refine command); this skill is the kernel-side interface to it. Call it directly from the Python REPL:

await refine.status()
await refine.run()
await refine.run("create a memory about always checking git status before committing")
await refine.run("promote the error-handling pattern to a global skill", global_=True)

API

  • await refine.status() — current refine state as a dict: pending (whether a requested refine is already queued for this turn) and in_flight (whether a refine is currently planning or applying).
  • await refine.run(instructions=None, global_=False) — schedule refinement. Returns {"scheduled": True} immediately, or {"scheduled": False, "reason": ...} when refinement cannot start. Optional instructions focus the refinement on a specific observation. Set global_=True to target the global harness store (cross-session); omit for local (session-scoped) refinement.

Rules

  • Refinement never runs mid-cell. A scheduled refinement runs when the current turn ends; the harness applies changes and rebuilds the system prompt, then resumes you automatically. Continue working normally after calling it.
  • One request per turn is enough; calling run again before the turn ends only updates the instructions.
  • Use refinement after observing a repeated failure, a reusable tactic, a repeated delegation role, or a behavior policy worth persisting. Do not rewrite the whole harness when a focused memory, skill, prompt note, or subagent spec is enough.

Signals

GitHub stars
22k
Forks
2k
Last commit
Oct 2026

Questions

Does refinement run immediately when I call refine.run?
No. refine.run returns {"scheduled": True} right away, but refinement never runs mid-cell. It runs when the current turn ends, then the harness applies changes and rebuilds the system prompt.
What does refine.status() return?
A dict with pending, whether a requested refine is already queued for this turn, and in_flight, whether a refine is currently planning or applying.
Advanced
Item type
skill
Key
refine-primeintellect-ai
Source
github.com/primeintellect-ai/prime-agent