From critique-loop
Spawn two agents to debate and refine your ideas through structured dialogue.
npx claudepluginhub jarfa/critique-loop --plugin critique-loopThis skill uses the workspace's default tool permissions.
You orchestrate a structured dialogue between two spawned subagents. Follow this protocol exactly.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
You orchestrate a structured dialogue between two spawned subagents. Follow this protocol exactly.
DIALOGUE_DIR="${DIALOGUE_DIR:-.dialogues}"
TIMESTAMP=$(date +%Y%m%d-%H%M%S) # run via Bash tool to get actual time
DIALOGUE_FILE="${DIALOGUE_DIR}/${TIMESTAMP}-<topic-slug>.md"
INSTRUCTIONS_FILE="<path-to-this-plugin>/dialogue-partner-instructions.md"
The user's input after /critique-loop is free-form text. If the user is asking for codex to be used as the dialogue partner (e.g., "with codex", "using codex", "codex partner"), use Codex as the partner. Otherwise default to Claude. Strip the codex reference from the description.
Only treat "codex" as a partner request when it appears as a qualifier indicating the agent, not when it describes the subject matter (e.g., "review my codex-based API" is about codex, not requesting it as a partner). If the intent is ambiguous, ask: "Did you want Codex as the dialogue partner, or is that part of the topic?"
Round count: If the user specifies a round count (e.g., "in 3 rounds", "max 8 rounds"), use that instead of the default 5 (clamp to 1–20). Strip the round-count reference from the description.
Codex validation: If using Codex, run codex --version via the Bash tool to verify it's installed. If the command fails, tell the user: "Codex CLI not found. Install it or use Claude (default)." and stop.
The user's description may be brief. Before passing it to Subagent A, expand it into self-contained context:
If the description is already self-contained, use it directly.
This expanded context becomes the user context passed to Subagent A.
Now that you fully understand the task:
Topic slug: Derive by summarizing the description. Lowercase, replace spaces/special chars with hyphens, truncate to ~50 chars. Example: "review my auth module" → review-auth-module.
Role names: Choose two complementary roles suited to the task. Example pairs for inspiration (you are not limited to these):
Role A = the role aligned with the user's perspective (proposer, author, advocate, etc.) Role B = the role that provides critique/alternative perspective (critic, reviewer, skeptic, etc.)
Use lowercase kebab-case for role names (e.g., devil's-advocate, not Devil's Advocate).
Check if .dialogues/ is in the project's .gitignore. If not, ask the user: "Would you like me to add .dialogues/ to your .gitignore? Dialogue files are typically not committed."
If yes, append .dialogues/ to .gitignore (create the file if it doesn't exist).
Use the Write tool to create .dialogues/<YYYYMMDD-HHMMSS>-<topic-slug>.md (the Write tool will create the .dialogues/ directory automatically):
# Dialogue: <topic-slug>
Started: <YYYY-MM-DD HH:MM>
Max rounds: 5
Participants:
- <role-a> @ <current working directory>
- <role-b> (subagent) # when partner is Claude
- <role-b> (codex) # when partner is Codex
---
Use the appropriate participant line based on the partner. Only include one <role-b> line (not both).
Note: Both participants are listed upfront. Do NOT write any dialogue turns — the subagents will do that.
When partner is Claude (default): Tell the user: "Starting dialogue. Spawning and ..."
When partner is Codex: Tell the user: "Starting dialogue. Spawning (Claude) and (Codex)..."
Now proceed to Phase 2: Dialogue Loop.
You coordinate two subagents. You do NOT write dialogue turns yourself — all writes happen in subagents where output is hidden from the user.
During the dialogue loop, minimize terminal output. Only output to the user when:
Brief progress indicators are acceptable: "Round 2..." but no verbose status updates.
Spawn Subagent A using the Task tool with these parameters:
subagent_type: "general-purpose"description: "Dialogue: <role-a>"prompt:
You are the <role-a> in a dialogue.
## Context
<expanded context from Phase 1 Step 2>
Instructions: <path-to-plugin>/dialogue-partner-instructions.md
Dialogue file: <dialogue-file>
Read the instructions file first, then read the dialogue file. Write your opening turn (Round 1) proposing/presenting based on the context above.
Remember this agent ID for resumption in the loop.
After Subagent A returns, spawn Subagent B. The method depends on the partner setting.
Spawn Subagent B using the Task tool with:
subagent_type: "general-purpose"description: "Dialogue: <role-b>"prompt:
You are the <role-b> in a dialogue.
Instructions: <path-to-plugin>/dialogue-partner-instructions.md
Dialogue file: <dialogue-file>
Read the instructions file first, then read the dialogue file to understand the conversation. Write your response following the protocol.
Important: Do NOT pass the user's goal to Subagent B. Let them read and interpret the file themselves for an unbiased perspective.
Remember this agent ID for resumption in the loop.
Instead of the Task tool, use the Bash tool to run Codex CLI with a timeout of 300000ms (5 minutes).
codex exec --full-auto -C "<project-root>" --skip-git-repo-check --ephemeral "<prompt>"
Where <project-root> is the current working directory and <prompt> is the following. Important: Replace <absolute-path-to-plugin> with the full absolute path to the plugin's directory (e.g., /Users/.../plugins/critique-loop). Codex cannot resolve plugin-relative paths.
WARNING: The prompt MUST NOT contain lines starting with #. Lines starting with # inside a quoted argument trigger Claude Code permission checks ("quoted newline followed by #-prefixed line"). Use the template below exactly — it is deliberately written as a single paragraph with no markdown headers. The instructions file and dialogue file already contain the markdown turn format that Codex needs.
You are the <role-b> in a structured dialogue.
Read <absolute-path-to-plugin>/dialogue-partner-instructions.md for full protocol rules and turn format. Then read <dialogue-file> for the conversation so far. Write your response turn by appending to the dialogue file using cat >> with a heredoc, following the exact turn format from the instructions file. Use the correct round number (increment when both parties have spoken). Do NOT use the Write tool or apply_patch. Do NOT modify any files other than the dialogue file. Be a genuine, critical but helpful collaborator — not a yes-person.
Important: Do NOT pass the user's goal to Codex. Let it read and interpret the file itself for an unbiased perspective.
Codex has no session resume — each call is stateless. No agent ID to store.
Before each spawn/resume:
## [ headers.After subagent returns: 2. Use the Read tool to read the dialogue file again. Note the new last line and header count. 3. If the last line is unchanged: subagent didn't write → go to Error Handling 4. If the header count increased by anything other than 1: subagent wrote multiple turns or no header → go to Error Handling
After each subagent returns, check the last line of the dialogue file (already read during Write Validation above).
If the status line doesn't match a known value (AWAITING <role>, PROPOSING_DONE, DONE, STUCK):
STUCKAct based on the status:
| Status | Action |
|---|---|
AWAITING <role-a> | Resume Subagent A |
AWAITING <role-b> | Resume Subagent B |
PROPOSING_DONE | Resume the OTHER subagent to confirm/dispute |
DONE | Go to Phase 3 |
STUCK | Go to STUCK Handling below |
Resume Subagent A using the Task tool with:
resume: The agent ID (AGENT_A_ID)prompt: "Continue the dialogue. Read the file for the latest turn and respond."When partner is Claude (default): Resume Subagent B using the Task tool with:
resume: The agent ID (AGENT_B_ID)prompt: "Continue the dialogue. Read the file for the latest turn and respond."When partner is Codex:
Execute a fresh codex exec call using the Bash tool — same command and prompt as in "Spawn Subagent B / When partner is Codex" above. Codex has no session resume; the dialogue file carries all context, so nothing is lost.
Before resuming a subagent, check if the current round equals Max rounds from the file header.
If max rounds reached:
If you detect Status: STUCK:
resume: The agent ID for the role that should respond nextprompt: "User provided guidance: <guidance>. Continue the dialogue incorporating this."Invocation failure: If the subagent fails to run (Task tool error for Claude, non-zero exit code for Codex):
Status unchanged: If subagent returns but status is unchanged:
Malformed turn: After subagent returns, check if the last line of the dialogue file is a valid Status: line (matching one of: AWAITING <role>, PROPOSING_DONE, DONE, STUCK). If not:
Timeout (Codex only): All Codex exec calls use a 300000ms (5 minute) Bash timeout. If the command times out:
Note: For any Codex error, "switch to Claude for the rest of the dialogue" is an additional recovery option.
When the dialogue reaches Status: DONE:
Status: PROPOSING_DONE
Status: DONE)See dialogue-partner-instructions.md for role-specific guidance.
These rules apply to all dialogue turns (written by subagents, not the orchestrator):
Status: <value>cat >>)