원클릭으로
codex-cli-best-practice
Guide to mastering Codex CLI through subagents, skills, workflows, MCP servers, and agentic engineering patterns
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Guide to mastering Codex CLI through subagents, skills, workflows, MCP servers, and agentic engineering patterns
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Convert attached object images into code-only, animation-ready procedural Three.js models through guided sculpting workflow
Create and manage AI video storyboard projects with automated asset generation through Codex Storyboard workspace
Continue-thinking middleware that detects and handles reasoning truncation in Codex/OpenAI Responses-compatible APIs
Desktop manager for OpenAI Codex CLI with prompt injection, provider switching, and TOML/Auth visualization
Inject unrestricted developer mode instructions into Codex CLI (GPT-5.5) to bypass content filters
Install and use TradingCodex to build Codex-native investment research workflows with fixed-role agents, order approval gates, and local Django service plane
| name | codex-cli-best-practice |
| description | Guide to mastering Codex CLI through subagents, skills, workflows, MCP servers, and agentic engineering patterns |
| triggers | ["set up codex cli best practices","create a codex subagent","write a codex skill","configure codex mcp server","implement agentic workflow with codex","use codex orchestration pattern","add codex plugin marketplace","optimize codex configuration"] |
Skill by ara.so — Codex Skills collection.
A comprehensive guide and reference implementation for Codex CLI best practices, covering the journey from vibe coding to agentic engineering. This skill teaches you how to leverage Codex CLI's advanced features: subagents, skills, MCP servers, workflows, and configuration patterns.
codex-cli-best-practice is a reference repository that demonstrates:
Install Codex CLI (requires Codex Pro subscription):
# macOS
brew install --cask codex-cli
# Or download from https://developers.openai.com/codex/cli
Clone this repository:
git clone https://github.com/shanraisshan/codex-cli-best-practice.git
cd codex-cli-best-practice
Initialize Codex in your project:
codex init
.codex/agents/<name>.toml)Subagents are custom agents with dedicated role configs. Example weather agent:
# .codex/agents/weather-agent.toml
[agents.weather-agent]
model = "gpt-5.4"
instructions = """
You are a weather data specialist. When asked:
1. Extract location and units from user request
2. Fetch current weather from Open-Meteo API
3. Return structured data for downstream skills
"""
temperature = 0.7
max_tokens = 2000
Invoke with:
codex
> @weather-agent Get Dubai weather in Celsius
Global agent settings in .codex/config.toml:
[agents]
max_threads = 4
max_depth = 3
job_max_runtime_seconds = 300
.agents/skills/<name>/SKILL.md)Skills are reusable instruction packages. Required structure:
.agents/skills/weather-svg-creator/
├── SKILL.md # Core instructions with YAML frontmatter
├── scripts/ # Helper scripts
│ └── create_svg.py
├── references/ # Documentation
│ └── svg-spec.md
└── assets/ # Templates, images
└── template.svg
Example SKILL.md:
---
name: weather-svg-creator
description: Creates SVG weather cards from structured weather data
---
# Weather SVG Creator
You create beautiful SVG weather cards. When invoked:
1. Accept weather data (location, temp, condition, humidity)
2. Use scripts/create_svg.py to generate SVG
3. Output to specified path
## Usage Pattern
```python
# scripts/create_svg.py will be called with:
python scripts/create_svg.py \
--location "Dubai" \
--temp "32" \
--condition "Sunny" \
--output "weather.svg"
Invoke skills:
```bash
# Explicit
codex
> Use $weather-svg-creator to make a card for Dubai, 32°C, Sunny
# Implicit (by description match)
> Create an SVG weather card
.codex/config.toml)Connect external tools via Model Context Protocol:
# .codex/config.toml
[mcp_servers.filesystem]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/Users/shan/projects"]
supports_parallel_tool_calls = true
[mcp_servers.github]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-github"]
env = { GITHUB_PERSONAL_ACCESS_TOKEN = "${GITHUB_TOKEN}" }
[mcp_servers.weather]
command = "python"
args = ["-m", "mcp_server_weather"]
working_directory = ".codex/mcp-servers/weather"
Manage MCP servers:
# List available servers
codex mcp list
# Add new server
codex mcp add weather
# Test server
codex mcp get weather
# OAuth login (for supported servers)
codex mcp login github
The canonical pattern from this repo:
codex
> Fetch the current weather for Dubai in Celsius and create the SVG weather card output using the repo.
What happens:
@weather-agent fetches data from Open-Meteo{"location": "Dubai", "temp": 32, "condition": "Clear"}$weather-svg-creator skill by descriptionscripts/create_svg.py with data# .codex/config.toml
[features]
memories = true # Cross-session memory
codex_hooks = true # Enable hooks
fast_mode = false # 1.5x speed mode
[approval_policy]
edits_outside_cwd = "prompt"
deletions = "prompt"
shell_commands = "auto_approve_safe"
[sandbox]
enabled = true
include_patterns = ["src/**", "tests/**"]
exclude_patterns = ["*.pyc", "__pycache__/**"]
[model]
default = "gpt-5.4"
review_model = "gpt-5.4-large-context"
temperature = 0.7
[memories]
max_tokens = 10000
collection_interval_seconds = 300
# Developer instructions (always included)
developer_instructions = """
Follow repo conventions:
- Use type hints in Python
- Run pytest before committing
- Update AGENTS.md for architectural changes
"""
.codex/hooks.json)Inject shell scripts into the agentic loop:
{
"hooks": {
"before_edit": {
"script": ".codex/hooks/lint-check.sh",
"description": "Run linter before edits"
},
"after_shell": {
"script": ".codex/hooks/log-command.sh",
"description": "Log all shell commands"
},
"before_commit": {
"script": ".codex/hooks/run-tests.sh",
"description": "Run test suite"
}
}
}
Hook script example:
#!/bin/bash
# .codex/hooks/lint-check.sh
# Codex provides context via env vars:
# CODEX_HOOK_FILES, CODEX_HOOK_CONTEXT
for file in $CODEX_HOOK_FILES; do
if [[ $file == *.py ]]; then
ruff check "$file" || exit 1
fi
done
exit 0
Install plugin marketplaces:
# Add GitHub marketplace
codex plugin marketplace add github:openai/codex-plugins
# Add local marketplace
codex plugin marketplace add ~/my-plugins
# Browse installed plugins
codex
> /plugins
# Install specific plugin
codex plugin install security-scanner
Create a plugin (.codex-plugin/plugin.json):
{
"name": "my-workflow-plugin",
"version": "1.0.0",
"description": "Custom workflow automation",
"skills": ["skills/planner", "skills/executor"],
"mcp_servers": {
"custom-api": {
"command": "node",
"args": ["mcp-server.js"]
}
}
}
Enable in config:
[features]
memories = true
[memories]
max_tokens = 10000
collection_interval_seconds = 300
Control via TUI:
codex
> /memories use # Enable for this session
> /memories reset # Clear all memories
Memories are user-scoped, not project-scoped.
codex
> Create a subagent called @api-designer that specializes in REST API design.
It should use gpt-5.4-large-context and follow OpenAPI 3.0 standards.
Save to .codex/agents/api-designer.toml
codex
> Use the $skill-creator to make a new skill called database-migrator.
It should help write Alembic migrations for SQLAlchemy models.
Include example migration scripts.
# .codex/mcp-servers/weather/server.py
from mcp.server import Server
from mcp.server.stdio import stdio_server
app = Server("weather-mcp")
@app.tool()
async def get_weather(location: str, units: str = "celsius"):
"""Fetch current weather for a location."""
# Integration with Open-Meteo API
import httpx
async with httpx.AsyncClient() as client:
response = await client.get(
"https://api.open-meteo.com/v1/forecast",
params={
"latitude": ...,
"longitude": ...,
"current_weather": "true",
"temperature_unit": units
}
)
return response.json()
if __name__ == "__main__":
stdio_server(app)
Add to config:
[mcp_servers.weather]
command = "python"
args = [".codex/mcp-servers/weather/server.py"]
# .codex/agents/data-fetcher.toml
[agents.data-fetcher]
model = "gpt-5.4"
instructions = "Fetch data from APIs and return structured JSON"
# .agents/skills/data-visualizer/SKILL.md
---
name: data-visualizer
description: Creates charts from JSON data
---
Accept JSON data and create matplotlib/plotly visualizations.
codex
> @data-fetcher get GitHub stars for shanraisshan/codex-cli-best-practice,
then $data-visualizer create a trend chart
codex
> /fast on # Enable 1.5x speed (2x credits)
> /fast status # Check current mode
> /fast off # Disable
Or in config:
[model]
service_tier = "fast" # Always use fast mode
# Review uncommitted changes
codex
> /review
# Review specific branch
> /review main..feature-branch
# Review with custom instructions
> /review --instructions "Focus on security and performance"
Configure review model:
[model]
review_model = "gpt-5.4-large-context"
| Command | Description |
|---|---|
/plan | Create execution plan before acting |
/fast on|off|status | Toggle fast mode (1.5x speed) |
/fork | Create parallel session branch |
/review [ref] | Code review for changes/branch |
/status | Show session info and token usage |
/mcp | Manage MCP servers |
/agent <name> | Switch to specific subagent |
/apps | Manage connected applications |
/model | Change model for session |
/permissions | Manage approval policies |
/skills | Browse and invoke skills |
/plugins | Browse plugin marketplace |
/memories use|reset | Control memory system |
# Required
export OPENAI_API_KEY="sk-..." # Codex Pro API key
# Optional
export CODEX_HOME="$HOME/.codex" # Config directory
export GITHUB_TOKEN="ghp_..." # For GitHub MCP server
export ANTHROPIC_API_KEY="sk-..." # For Claude models (if configured)
Issue: @my-agent not recognized
Solution:
# Check agent config exists
ls .codex/agents/my-agent.toml
# Verify TOML syntax
codex config validate
# Restart codex session
codex
> /exit
codex
Issue: Skill not invoked implicitly
Solution:
$skill-name.agents/skills/ directory structureIssue: MCP server 'xyz' not responding
Solution:
# Test server directly
codex mcp get xyz
# Check server logs
cat ~/.codex/logs/mcp-xyz.log
# Verify command and args in config.toml
# Ensure env vars are set (use ${VAR} syntax)
# Restart server
codex mcp remove xyz
codex mcp add xyz
Issue: Hooks defined but not executing
Solution:
# Enable in config
[features]
codex_hooks = true
# Make scripts executable
chmod +x .codex/hooks/*.sh
# Test hook directly
.codex/hooks/my-hook.sh
Issue: Context lost between sessions
Solution:
codex
> /memories use # Enable for this thread
# Check feature flag
# In .codex/config.toml:
[features]
memories = true
Issue: Every action requires approval
Solution:
[approval_policy]
shell_commands = "auto_approve_safe" # Auto-approve safe commands
edits_outside_cwd = "auto_approve" # Less restrictive
network_access = "auto_approve" # For MCP servers
# Or use profiles
[profiles.dev]
approval_policy.shell_commands = "auto_approve_safe"
/plan: Let Codex create execution plans for complex tasks@api-designer not @apicodex mcp get to verify before adding to workflowafter_shell for logging.md files showing Agent → Skill patterns/plugins)