iTranslated by AI
Assigning Another AI Agent (Codex, etc.) as a Consultant for Claude Code
Background
I rely heavily on Claude Code daily, but the reality is that I can't leave everything completely up to it.
- Reviewing at the planning stage - I want to confirm, "Is that approach okay?"
- Course correction during implementation - I want to offer guidance when things seem to be heading in the wrong direction.
- Checking upon completion - I want to ensure nothing has been overlooked.
Ultimately, I felt anxious unless I was right beside it, needing to check in frequently. I thought, "If only Claude Code could make better autonomous judgments, I could delegate more to it..."
That's when I discovered that Codex has MCP server capabilities. I wondered, "Could I make Codex act as an advisor or reviewer on my behalf?" — that was the motivation for creating this Agent Skill.
Initially, I tried implementing it as an MCP server, but it was unstable, experiencing hangs and slow responses. When Agent Skills were introduced, I reimplemented it that way, and it has been running stably since.
What I built
I created an Agent Skill that allows Claude Code to consult with other AI agents (via CLI).
Agent Skills Prepared:
| Skill Name | Consultant | Use Case |
|---|---|---|
| ask-codex | Codex CLI | Consultation/Review requests to Codex |
| ask-gemini | Gemini CLI | Consultation/Review requests to Gemini CLI |
| ask-peer | Sub-agent | Consultation acting as a peer engineer |
ask-codex and ask-gemini call external AI CLIs. ask-peer uses Claude Code's sub-agent feature to launch an agent within the same Claude session that acts as a "peer engineer."
I have also prepared a skill for other AI agents (like Codex) to consult with Claude.
| Skill Name | Consultant | Use Case |
|---|---|---|
| ask-claude | Claude Code | Consultation/Review requests from Codex, etc., to Claude |
Usage
Basic usage
You can simply ask naturally, like "Consult Codex" or "Have Gemini review this."
You: Please add OAuth authentication. Once you've made a plan, have Codex review it.
Claude Code: I've created a plan for adding OAuth authentication. I will now ask Codex for a review.
Codex: Let me confirm a few things.
1. How do you plan to handle session management? Will it coexist with the existing JWT?
2. Have you considered a fallback if OAuth fails?
...
You can also call them directly using slash commands like /ask-codex, /ask-gemini, or /ask-peer.
When you want a broad range of opinions, you can prompt multiple AIs to brainstorm, for example: "Try consulting both Codex and Peer." It's interesting because you get different perspectives from different models.
Integration with CLAUDE.md
By adding the following to your CLAUDE.md, you can build a workflow where reviews are automatically triggered at the start and end of a task.
## Consultation Rules
- **Important**:
- Always have Codex review the work plan at the start of a task.
- Always have Codex check for deficiencies/omissions upon task completion.
In addition to the above, consult Codex if you encounter the following situations during work:
- Problems occurred during task execution.
- Faced with multiple options and unsure of the decision.
- Unable to identify the cause of an error or unexpected behavior.
- **Note**:
You and Codex are excellent engineers with different characteristics. Keep the following in mind when consulting Codex:
- Do not blindly follow Codex's suggestions; understand the rationale and reasons behind them.
- If your analysis differs from Codex's opinion, compare and consider both perspectives.
- Make the final decision yourself after synthetically evaluating both opinions.
This allows a natural workflow: Task Request → Planning → Codex Review → Implementation → Final Review → Completion. Since the review happens automatically without having to say "Review with Codex" every time, I can now confidently delegate tasks without staying glued to the screen.
By the way, I didn't include the "Note" section initially. However, during operation, I noticed Claude would sometimes follow Codex blindly even when Claude was correct. So, I added the rule to "not follow suggestions blindly and make decisions by synthetically evaluating both opinions."
Additionally, if you create AGENTS.md (for Codex) or GEMINI.md (for Gemini CLI) as symbolic links to CLAUDE.md, Codex and Gemini can provide advice while possessing the same level of domain knowledge as Claude.
Since linking CLAUDE.md directly would cause the "Consultation Rules" to be read by Codex or Gemini as well, I write my "Consultation Rules" in the user-level file (~/.claude/CLAUDE.md).
Features of Each Skill
ask-codex / ask-gemini
These are skills that call external AI CLIs.
Pros:
- Get reviews from the perspective of different models.
- Receive feedback based on different judgment criteria than Claude Code.
Notes:
- Each CLI must be installed in advance.
- Since these call external processes, there is a slight overhead.
ask-peer
This skill uses Claude Code's sub-agent feature. Instead of calling an external CLI, it launches another agent within Claude Code.
Pros:
- No additional CLI installation required.
- Relatively fast response times.
Characteristics:
- Prompt design is focused on acting as a "peer engineer."
- Frankly points out problems and suggests alternatives.
How it Works
Implementing an Agent Skill is very simple.
Directory Structure (Example of ask-codex)
ask-codex/
├── .claude-plugin/
│ └── plugin.json # Plugin metadata
└── skills/
└── ask-codex/
└── SKILL.md # Skill definition
SKILL.md
---
name: ask-codex
description: Asks Codex CLI for coding assistance.
allowed-tools: Bash(codex:*)
---
# Ask Codex
Executes the local `codex` CLI to get coding assistance.
## Quick start
\`\`\`bash
codex exec "Your question or task here"
\`\`\`
Refer to GitHub for the full version.
With just this, you can call it as the /ask-codex command from Claude Code.
My Experience
Since I started using these Agent Skills, it has become much easier to delegate tasks to Claude Code.
- Feedback at the planning stage - Reduced rework after implementation.
- Detection of oversights - It points out considerations I had missed myself.
- No need to stay glued to the screen - By setting up automatic reviews in CLAUDE.md, I can leave it to run on its own.
It is a fascinating experience to have different AI agents consult with each other. Since each model has different areas of focus, I sometimes receive unexpected insights.
Considerations
- Token/API usage - Tokens and API calls are consumed for every consultation.
- Make the final decision yourself - It is important not to follow AI opinions blindly and to exercise your own judgment.
Conclusion
I tried to solve the challenge of "needing to stay right beside it" through the form of consultation between AI agents.
I have released these Agent Skills as a plugin. If you're interested, please give them a try.
GitHub: hiroro-work/claude-plugins
*Note: Please also check Postscript: Risks of Third-Party Plugins before installation.
# Claude Code Plugin Marketplace
claude plugin marketplace add hiroro-work/claude-plugins
claude plugin install ask-codex@hiropon-plugins
claude plugin install peer@hiropon-plugins
ask-codex, ask-claude, and ask-gemini can also be installed from Skills.sh.
# Skills.sh
npx skills add hiroro-work/claude-plugins
Postscript: Risks of Third-Party Plugins
After publishing this article, I read an article warning about the security risks of plugins created by third parties (Skills Marketplace).
Reference: Is the "Stray" (Market) Skill you picked up causing security troubles?
When I originally wrote this article, I thought that people who were concerned would simply refer to the public code and make their own, but I realized this post might encourage people to casually install third-party plugins without considering the risks. Therefore, I am adding this section.
Plugins created by third parties may include those created with malicious intent. It is advisable to keep the following points in mind when installing plugins:
- Verify the contents of the code before installation
- Use only trusted sources
The code for the plugins introduced in this article is also available on GitHub. If you have concerns, I recommend checking the contents yourself before use or using it as a reference to build your own.
This article is cross-posted to Zenn/Qiita.
Discussion
同じ課題を抱えていて、同じ解決方法を選択していて記事ネタが被ってしまっていました😅
こちらの内容も参考にさせていただきます
ご連絡ありがとうございます 🙏
CodexのMCP機能があったおかげでこの仕組みにたどり着けたのでとてもありがたい機能ですが安定性という意味では今のところスキルでCLI実行のほうがよさそうですよね。
こちらこそ参考にさせていただきます!