home / skills / renocrypt / latex-arxiv-skill / collaborating-with-claude

collaborating-with-claude skill

/.codex/skills/collaborating-with-claude

This skill enables seamless Claude Code collaboration to propose and review code changes via a bridge, keeping your edits centralized and auditable.

npx playbooks add skill renocrypt/latex-arxiv-skill --skill collaborating-with-claude

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
5.8 KB
---
name: collaborating-with-claude
description: Use the Claude Code CLI to consult Claude and delegate coding tasks for prototyping, debugging, and code review. Supports multi-turn sessions via SESSION_ID. Optimized for low-token, file/line-based handoff.
metadata:
  short-description: Delegate to Claude Code CLI
---

# Collaborating with Claude Code (Codex)

Use Claude Code CLI as a collaborator while keeping Codex as the primary implementer.

This skill provides a lightweight bridge script (`scripts/claude_bridge.py`) that returns structured JSON and supports multi-turn sessions via `SESSION_ID`.

## When to use
- You want a second opinion (design tradeoffs, edge cases, missing tests).
- You want Claude to propose or review a **unified diff** (Claude does not edit files).
- You want multi-turn back-and-forth while you implement locally.

## When not to use
- The task is trivial or one-shot (do it directly in Codex).
- You need authoritative facts that require browsing/citations (Claude may guess).
- You might paste sensitive data (secrets, private keys, prod logs).

## Core rules
- Claude is a collaborator; you own the final result and must verify changes locally.
- Do not invoke `claude` directly; always use the bridge script (`scripts/claude_bridge.py`) so output/session handling stays consistent.
- Prefer file/line references over pasting snippets. Run the bridge with `--cd` set to the repo root (it sets the `claude` process working directory); use `--add-dir` when Claude needs access to additional directories.
- For code changes, request **Unified Diff Patch ONLY** and forbid direct file modification.
- Always run the bridge script with `--help` first if you are unsure of parameters.
- Always capture `SESSION_ID` and reuse it for follow-ups to keep the collaboration conversation-aware.
- For automation, prefer `--SESSION_ID` (resume). Session selectors are mutually exclusive: choose one of `--SESSION_ID`, `--continue`, or `--session-id`.
- Keep a short **Collaboration State Capsule** updated while this skill is active.
- Default timeout: when invoking via the Codex command runner, set `timeout_ms` to **600000 (10 minutes)** unless a shorter/longer timeout is explicitly required.
- Default model: prefer `sonnet` for routine work; use `opus` only for complex tasks or when explicitly requested.
- Ensure Claude Code is logged in before running headless commands (run `claude` and `/login` once if needed).
- Streamed JSON requires `--verbose`; the bridge enables this automatically.

## Model selection

Claude Code supports model aliases, so you can use `--model sonnet` / `--model opus` instead of hard-coding versioned model IDs.

- If you omit `--model`, Claude Code uses its configured default (typically from `~/.claude/settings.json`, optionally overridden by `.claude/settings.json` and `.claude/settings.local.json`).
- If you need strict reproducibility, pass a full model name via `--model <full-name>`.

## Quick start (shell-safe)

⚠️ If your prompt contains Markdown backticks (`` `like/this` ``), do **not** pass it directly via `--PROMPT "..."` (your shell may treat backticks as command substitution). Use a heredoc instead; see `references/shell-quoting.md`.

```bash
PROMPT="$(cat <<'EOF'
Review src/auth.py around login() and propose fixes.
OUTPUT: Unified Diff Patch ONLY.
EOF
)"
python3 .codex/skills/collaborating-with-claude/scripts/claude_bridge.py --cd "." --model sonnet --PROMPT "$PROMPT" --output-format stream-json
```

**Output:** JSON with `success`, `SESSION_ID`, `agent_messages`, and optional `error` / `all_messages`.

## Multi-turn sessions

```bash
# Start a session
PROMPT="$(cat <<'EOF'
Analyze the bug in foo(). Keep it short.
EOF
)"
python3 .codex/skills/collaborating-with-claude/scripts/claude_bridge.py --cd "." --PROMPT "$PROMPT" --output-format stream-json

# Continue the same session
PROMPT="$(cat <<'EOF'
Now propose a minimal fix as Unified Diff Patch ONLY.
EOF
)"
python3 .codex/skills/collaborating-with-claude/scripts/claude_bridge.py --cd "." --SESSION_ID "<SESSION_ID>" --PROMPT "$PROMPT" --output-format stream-json
```

## Prompting patterns (token efficient)

Use `assets/prompt-template.md` as a starter when crafting `--PROMPT`.

### 1) Ask Claude to open files itself
Provide:
- Entry file(s) and approximate line numbers
- Objective and constraints
- Output format (diff vs analysis)

Avoid:
- Pasting large code blocks
- Multiple competing objectives in one request

### 2) Enforce safe output for code changes
Append this to prompts when requesting code:
- `OUTPUT: Unified Diff Patch ONLY. Strictly prohibit any actual modifications.`

### 3) Use Claude for what it’s good at
- Alternative solution paths and edge cases
- UI/UX and readability feedback
- Review of a proposed patch (risk spotting, missing tests)

## Verification
- Smoke-test the bridge: `python3 .codex/skills/collaborating-with-claude/scripts/claude_bridge.py --help`.
- If you need a session: run one prompt with `--output-format stream-json` and confirm the JSON contains `success: true` and a `SESSION_ID`.
- Note: `--output-format text` won’t include a newly generated session id; use `stream-json`/`json` to capture it. If you resume with `--SESSION_ID` in `text` mode, the bridge echoes that `SESSION_ID` in its JSON output.

## Safety & guardrails
- Never paste secrets (private keys, API keys, seed phrases) into prompts.
- For code changes, request **Unified Diff Patch ONLY** and apply changes yourself.
- Treat Claude output as suggestions; verify locally (tests, lint, build) before merging.

## Collaboration State Capsule
Keep this short block updated near the end of your reply while collaborating:

```text
[Claude Collaboration Capsule]
Goal:
Claude SESSION_ID:
Files/lines handed off:
Last ask:
Claude summary:
Next ask:
```

## References
- `assets/prompt-template.md` (prompt patterns)
- `references/shell-quoting.md` (shell quoting/backticks)

Overview

This skill lets you collaborate with Claude Code via a lightweight bridge script to consult, review, and propose code changes while keeping Codex as the primary implementer. It supports multi-turn sessions using SESSION_ID and is optimized for low-token, file/line-based handoffs. The workflow enforces safe, verifiable output such as Unified Diff patches that you apply locally.

How this skill works

You run a bridge script that communicates with Claude Code and returns structured JSON, including success, SESSION_ID, agent messages, and optional errors. The bridge supports streaming JSON, multi-turn sessions, model selection, and working-directory control so Claude can reference files by path and line ranges rather than requiring pasted snippets. For code edits, ask Claude to produce Unified Diff Patch ONLY and apply the patch locally after verification.

When to use it

  • You want a second opinion on design tradeoffs, edge cases, or missing tests.
  • You need Claude to propose or review a Unified Diff rather than directly modify files.
  • You want multi-turn back-and-forth while implementing locally and keeping context via SESSION_ID.
  • You prefer file/line references to reduce token usage and protect sensitive data.
  • You need a reviewer to spot risks, readability issues, or missing tests before merging.

Best practices

  • Always run the bridge script (do not invoke Claude directly) so session and output handling stays consistent.
  • Provide entry files and approximate line numbers instead of pasting large code blocks.
  • Request OUTPUT: Unified Diff Patch ONLY when asking for code changes and forbid direct modifications.
  • Capture and reuse SESSION_ID for follow-up prompts to maintain conversation-aware context.
  • Set a sensible default timeout (10 minutes when using the Codex runner) and prefer the sonnet model for routine tasks; use opus only for complex requests.
  • Keep a short Collaboration State Capsule updated to summarize goal, SESSION_ID, files/lines handed off, last ask, and next ask.

Example use cases

  • Start a session to analyze a failing unit test and then request a minimal Unified Diff fix while preserving conversation context.
  • Ask Claude to review a proposed patch and list edge cases or missing tests before you apply it.
  • Use file and line references to have Claude suggest refactors for a large module without pasting files into the prompt.
  • Run iterative design discussions: get tradeoff analysis, then request a sample patch, then ask for tests to validate the change.

FAQ

How do I capture and resume a session?

Use the SESSION_ID returned in the bridge JSON. Pass that same SESSION_ID on subsequent bridge runs to continue the multi-turn conversation.

What output format should I request for edits?

Request Unified Diff Patch ONLY and output as stream-json or json so the bridge returns structured data and a SESSION_ID for follow-ups.