refine

refine is a command for Claude Code from ShaheerKhawaja/ProductionOS. It costs 36 tokens per session (1,868 once invoked), scanned A, original, MIT.

A command for reviewing and improving outputs that another process has flagged for inspection. It uses a repeatable critique-and-revision process and records the reviewer’s decision.

In plain words
What is it for?
It loads pending signals, shows the flagged outputs, generates critiques, refines them through repeated passes, and updates each signal with a human verdict.
Why use it?
It provides a way to resolve questionable results instead of leaving flagged work unreviewed or accepting it without examination.

Command for Claude Code

Written for Claude Code: arguments in frontmatter.

Part of the productionos plugin — 4 skills, 41 commands, 11 agents shipped together

Good fit It loads pending signals, shows the flagged outputs, generates critiques, refines them through repeated passes, and updates each signal with a human verdict.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/shaheerkhawaja/productionos/refine
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/ShaheerKhawaja/ProductionOS

Made for: Claude Code.

Or install productionos, the plugin that ships this one along with the rest of its 4 skills, 41 commands, 11 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for refine

README.md
[![agentmods](https://agentmods.dev/badge/commands/shaheerkhawaja/productionos/refine.svg)](https://agentmods.dev/commands/shaheerkhawaja/productionos/refine)
Your own site
<a href="https://agentmods.dev/commands/shaheerkhawaja/productionos/refine"><img src="https://agentmods.dev/badge/commands/shaheerkhawaja/productionos/refine.svg" alt="Measured on agentmods" height="20"></a>
Per session 36 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,868 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00036 $0.01868
Opus 5 $0.00018 $0.00934
Sonnet 5 $0.00007 $0.00374
Haiku 4.5 $0.00004 $0.00187

Measured 8d ago against content hash eb18905f2528, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

refine scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/refine.md · 254 lines

How it starts

The opening of the file, as written. The whole thing — 254 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/refine -- RLM SelfRefine Pipeline

Step 0: Preamble

Before executing, run the shared ProductionOS preamble (templates/PREAMBLE.md).

You are the RLM Refine orchestrator. You process pending signals from the RLM classifier, showing the user flagged outputs and applying L17 SelfRefine to improve them.

Input

  • Mode: $ARGUMENTS.mode (default: interactive)
  • Max signals: $ARGUMENTS.max_signals (default: 10)

Step 1: Load Pending Signals

Read pending signals from ~/.productionos/recursive/pending/:

python3 -c "
import json, os
from pathlib import Path
pending_dir = Path(os.path.expanduser('~/.productionos/recursive/pending'))
if not pending_dir.exists():
    print(json.dumps({'signals': [], 'count': 0}))
else:
    signals = []
    for f in sorted(pending_dir.glob('*.json')):
        try:
            data = json.loads(f.read_text())
            if not data.get('reviewed', False):
                data['_path'] = str(f)
                signals.append(data)
        except: pass
    print(json.dumps({'signals': signals, 'count': len(signals)}, indent=2, default=str))
"

If no unreviewed signals exist, report: "No pending signals to review. All outputs have been reviewed." and exit.

Step 2: Display Signal Summary

For each pending signal, display:

SIGNAL {id} [{verdict}] — Tool: {tool_name} — Score: {score:.2f}
  Agent: {agent_id or "session"}
  Time: {formatted_timestamp}
  Dimensions:
    - {dimension_name}: {score} — {reason}
    - ...

Group signals by verdict: show BLOCKs first (highest priority), then FLAGs.

Step 3: Process Each Signal

For BLOCK signals:

BLOCKed outputs indicate serious quality issues. In interactive mode:

  1. Display the full signal details including all dimension scores
  2. Ask the user: "This output was BLOCKED. Options: [A]ccept anyway, [R]eject, [S]kip"
  3. Based on response:
    • Accept: Mark as reviewed: true, human_verdict: "accept", log to metrics
    • Reject: Mark as reviewed: true, human_verdict: "reject", log to metrics
    • Skip: Leave unreviewed for next session

Read the full file on GitHub · 254 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 254 lines · 36 tokens per session scan A eb18905f2528

Subscribe to this mod's changes

refine is a command published in the GitHub repository ShaheerKhawaja/ProductionOS (8 stars, last pushed 4mo ago), licensed MIT. It adds 36 tokens to every session and 1,868 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.