skill-codex 0.3.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,217 @@
1
+ ---
2
+ name: codex-bridge
3
+ description: Delegates bounded implementation work to OpenAI Codex via the codex_exec MCP tool, and uses Codex as an independent reviewer or second opinion. Use when the user asks to implement, write, generate, scaffold, port, refactor, migrate, or add tests for a well-scoped code task — especially phrases like "implement X", "write a function that", "generate tests for", "port this to", "refactor this file", "convert this", "add boilerplate", "create a script", "write a migration". Also use when the user asks for a second opinion, independent review, code review, or to double-check logic, security, or correctness of a diff. Do NOT use for architecture decisions, brainstorming, cross-module refactors needing deep context, or tasks under ~50 lines that are faster to do directly.
4
+ license: MIT
5
+ metadata:
6
+ author: Arystos
7
+ version: 0.8.0
8
+ mcp-server: skill-codex
9
+ category: developer-tools
10
+ ---
11
+
12
+ # Codex Bridge
13
+
14
+ This skill turns OpenAI Codex into a peer engineer you can delegate bounded implementation work to, and a second reviewer you can call for independent code review or technical consultation. It uses the `codex_exec` MCP tool provided by the `skill-codex` MCP server.
15
+
16
+ ## When to use this skill
17
+
18
+ Load this skill automatically when the user's request matches any of the following patterns:
19
+
20
+ **Delegation triggers** (use `delegate` workflow below):
21
+ - "implement X" / "write a function that X" / "create a script that X"
22
+ - "generate tests for X" / "add unit tests" / "scaffold tests"
23
+ - "port X to Y" / "convert X to Y" / "rewrite X in Y"
24
+ - "refactor this file" (single-file, clear target)
25
+ - "write a migration" / "create boilerplate for X"
26
+ - Any bounded, single-file or small multi-file code task with a clear spec
27
+
28
+ **Review triggers** (use `review` workflow below):
29
+ - "review my changes" / "review this diff" / "code review"
30
+ - "second opinion on this code" / "independent review"
31
+ - "check this for bugs" / "audit this for security issues"
32
+ - Before committing critical code (auth, payments, crypto, concurrency)
33
+
34
+ **Consult triggers** (use `consult` workflow below):
35
+ - "what do you think about this approach"
36
+ - "is this the right way to do X"
37
+ - "second opinion on my plan"
38
+ - Debugging when Claude has failed 3+ times on the same issue
39
+
40
+ ## When NOT to use this skill
41
+
42
+ Skip Codex and do the work yourself when:
43
+ - Task is <50 lines and faster to do directly
44
+ - Task requires deep conversation context Codex won't have
45
+ - Cross-module architectural refactor
46
+ - Ambiguous requirements needing user clarification
47
+ - Planning, brainstorming, or design decisions (Claude handles these)
48
+ - User explicitly asks you to do the work yourself
49
+
50
+ ## Workflows
51
+
52
+ ### Workflow 1: Delegate implementation (`delegate`)
53
+
54
+ Use when the user asks for a bounded implementation task with a clear spec.
55
+
56
+ **Steps:**
57
+
58
+ 1. **Verify the task is well-scoped.** If the request is vague, ask one clarifying question before delegating. A good delegation prompt has: exact file paths, specific change required, constraints (language, style, naming), and a clear "done" condition.
59
+
60
+ 2. **Announce the delegation.** Tell the user: `Delegating [task] to Codex.` Never invoke Codex silently.
61
+
62
+ 3. **Prepare a self-contained prompt.** Include:
63
+ - Exact file paths to create or modify (absolute or repo-relative)
64
+ - The specific change, with before/after examples if helpful
65
+ - Coding style constraints (e.g., "TypeScript strict, no `any`, immutable patterns")
66
+ - What success looks like (e.g., "tests pass, no new lint errors")
67
+
68
+ 4. **Call the `codex_exec` MCP tool** with:
69
+ ```
70
+ prompt: <the self-contained prompt>
71
+ mode: "full-auto"
72
+ requireGit: true
73
+ ```
74
+
75
+ 5. **Review Codex's output critically.** Run `git status --short` (catches new files that `git diff` misses), then `git diff`, to see exactly what changed. Check for:
76
+ - Introduced bugs, logic errors, or regressions
77
+ - Style violations against the project's conventions
78
+ - Files modified outside the requested scope
79
+ - Missing test coverage if tests were part of the task
80
+
81
+ 6. **Present the result with your assessment.** State what Codex did correctly, what needs adjustment, and either accept the changes or fix/re-delegate. Codex is a **peer, not an authority** — you own the final quality.
82
+
83
+ ### Workflow 2: Independent code review (`review`)
84
+
85
+ Use when the user wants a second-opinion review of a diff, branch, or commit.
86
+
87
+ **Steps:**
88
+
89
+ 1. **Determine the scope of the review:**
90
+ - No argument → run `git status --short` first to catch new untracked files (`??`), then collect `git diff` (unstaged) + `git diff --cached` (staged), and include the contents of any new untracked files — plain `git diff` is blind to them
91
+ - Branch name → `git diff <branch>...HEAD`
92
+ - SHA → `git show <sha>`
93
+ - If there are no changes at all, tell the user and stop.
94
+
95
+ 2. **Check diff size.** If the diff exceeds ~50,000 characters, summarize it first and warn the user that Codex will see a truncated version.
96
+
97
+ 3. **Call the `codex_exec` MCP tool** in read-only mode:
98
+ ```
99
+ prompt: "Review the following code changes. For each finding, specify: severity (CRITICAL/HIGH/MEDIUM/LOW), file and line, description, and suggested fix. Focus on: bugs, security, performance, error handling, readability.\n\n```diff\n<diff>\n```"
100
+ mode: "exec"
101
+ requireGit: true
102
+ ```
103
+
104
+ 4. **Assign an overall verdict** (you are the final judge, not a relay): **BLOCKED** (≥1 CRITICAL/HIGH), **WARNING** (only MEDIUM/LOW), or **APPROVED** (none). State it explicitly, e.g. `Verdict: BLOCKED — 1 CRITICAL`.
105
+
106
+ 5. **Present findings grouped by severity.** For each finding, add your own assessment: agree, disagree with reasoning, or add nuance. Note anything Codex missed that you think is important. End with a summary of actionable items.
107
+
108
+ 6. **If BLOCKED or WARNING, offer a bounded fix loop** (with the user's go-ahead): fix the issues you agree are real, re-run `codex_exec` on the updated diff to confirm the fixes and catch regressions, and repeat until APPROVED or **3 rounds max** — then stop and summarize what's left. The cap prevents runaway Codex quota use.
109
+
110
+ ### Workflow 3: Consult for a second opinion (`consult`)
111
+
112
+ Use when you want Codex's perspective on a plan, hypothesis, or technical decision — no files modified.
113
+
114
+ **Steps:**
115
+
116
+ 1. **Frame the question precisely.** Include:
117
+ - The specific question or plan to evaluate
118
+ - Relevant context: file paths, code snippets, constraints
119
+ - What kind of feedback you want (validation, alternatives, risks)
120
+
121
+ 2. **Call `codex_exec`** in read-only mode:
122
+ ```
123
+ prompt: "Provide your analysis and recommendation on the following question. Consider tradeoffs, alternatives, and risks. Be specific.\n\n<question with context>"
124
+ mode: "exec"
125
+ ```
126
+
127
+ 3. **Synthesize both perspectives.** Present Codex's analysis, then your own independent analysis. State where you agree/disagree with evidence. Give a recommended path forward with reasoning.
128
+
129
+ ## The `codex_exec` tool
130
+
131
+ The skill-codex MCP server exposes exactly one tool: `codex_exec`.
132
+
133
+ **Parameters:**
134
+
135
+ | Param | Type | Required | Description |
136
+ |-------|------|----------|-------------|
137
+ | `prompt` | string | yes | The prompt to send to Codex |
138
+ | `mode` | `"exec"` \| `"full-auto"` | no (default `"exec"`) | `exec` is read-only; `full-auto` allows file writes |
139
+ | `sandbox` | `"read-only"` \| `"workspace-write"` \| `"danger-full-access"` | no | Explicit sandbox policy; overrides `mode`. Use `danger-full-access` only when you understand the risk |
140
+ | `sessionId` | string | no | Resume a prior Codex session (the thread id from a previous response) so Codex keeps context across calls |
141
+ | `model` | string | no | Codex model to use. Omit to use Codex's configured default |
142
+ | `reasoningEffort` | `"minimal"` \| `"low"` \| `"medium"` \| `"high"` \| `"xhigh"` | no | How much reasoning effort Codex spends. Omit for the model's default |
143
+ | `review` | boolean | no | Run Codex's native diff-scoped review (`codex exec review`) instead of a freeform prompt |
144
+ | `reviewBase` | string | no | With `review`: diff against this base branch |
145
+ | `reviewCommit` | string | no | With `review`: review the changes introduced by this commit SHA |
146
+ | `cwd` | string | no | Working directory for Codex |
147
+ | `timeoutMs` | number | no | Override default 5min timeout |
148
+ | `requireGit` | boolean | no | Refuse to run if cwd is not a git repo (recommended `true` for `full-auto`) |
149
+
150
+ **Modes:**
151
+ - `exec` → read-only. Use for review and consult.
152
+ - `full-auto` → can modify files. Use only for delegate, and always with `requireGit: true`.
153
+
154
+ ## Examples
155
+
156
+ ### Example 1: Delegate — generate tests
157
+
158
+ **User says:** "Write unit tests for `src/util/platform.ts`. Use vitest. Cover the `getClaudeDir` and `getHomeDir` functions including Windows/macOS/Linux branches."
159
+
160
+ **Actions:**
161
+ 1. Announce: `Delegating test generation to Codex.`
162
+ 2. Call `codex_exec` with `mode: "full-auto"`, `requireGit: true`, and a prompt specifying: the target file, test framework (vitest), test file path (`__tests__/util/platform.test.ts`), the two functions to cover, the three OS branches, and the project convention (TS strict, no `any`).
163
+ 3. `git diff` → verify only the new test file was created, imports are correct, no existing files touched.
164
+ 4. Report: `Codex generated 6 tests covering all three OS branches. All pass locally. No files outside scope modified.`
165
+
166
+ ### Example 2: Review — pre-commit diff
167
+
168
+ **User says:** "Review my changes before I commit."
169
+
170
+ **Actions:**
171
+ 1. Run `git status --short` (to catch new untracked files), then `git diff` → capture unstaged changes (fall back to `git diff --cached` if empty).
172
+ 2. Call `codex_exec` with `mode: "exec"` and the review prompt.
173
+ 3. Present: 1 CRITICAL (missing null check, `src/runner/runner.ts:47` — confirmed), 2 MEDIUM (disagree with one, agree with the other), 1 LOW (style nit, skip).
174
+ 4. Offer to fix the CRITICAL and the confirmed MEDIUM.
175
+
176
+ ### Example 3: Consult — architecture question
177
+
178
+ **User says:** "Should I use a lock file or a mutex for the codex subprocess?"
179
+
180
+ **Actions:**
181
+ 1. Frame the question with context: existing `src/lock/` module, single-machine usage, Windows compatibility requirement.
182
+ 2. Call `codex_exec` with `mode: "exec"`.
183
+ 3. Synthesize: Codex recommends lock file for cross-process safety; your analysis confirms it's the right choice given Windows named-mutex quirks; recommend proceeding with lock file approach.
184
+
185
+ ## Troubleshooting
186
+
187
+ **Error: `codex` binary not found**
188
+ - Cause: Codex CLI not installed or not on PATH.
189
+ - Solution: Tell the user to install it (`npm i -g @openai/codex` or equivalent) and re-run.
190
+
191
+ **Error: Authentication required**
192
+ - Cause: User hasn't run `codex login`.
193
+ - Solution: Tell the user to run `codex login` (uses ChatGPT Plus/Codex subscription) or set `OPENAI_API_KEY`.
194
+
195
+ **Error: Lock file conflict**
196
+ - Cause: Another Codex subprocess is already running in the same workspace.
197
+ - Solution: Wait for it to finish, or check for stale lock (PID dead, >15 min old) and retry.
198
+
199
+ **Error: Recursion limit reached**
200
+ - Cause: Codex is running inside Codex (nested `codex_exec` calls).
201
+ - Solution: Do not delegate from within a Codex-initiated session. Claude should handle the task directly.
202
+
203
+ **Error: Timeout (5 min default)**
204
+ - Cause: Task is too large or Codex is stuck.
205
+ - Solution: Break the task into smaller delegations, or override `timeoutMs` for genuinely long-running work.
206
+
207
+ **Codex returns but made wrong changes**
208
+ - Do not accept blindly. Run `git diff`, evaluate, then either fix the issue yourself or re-delegate with a refined prompt that addresses the specific mistake.
209
+
210
+ ## Critical rules
211
+
212
+ - **Never invoke Codex silently.** Always tell the user what you are delegating and why.
213
+ - **After `full-auto` runs, check `git status --short` then `git diff`.** `git status` catches new files `git diff` misses; verify scope and correctness before presenting results.
214
+ - **Fail soft.** If `codex_exec` errors (Codex missing, auth expired, offline), say so and continue with Claude-only work — never block the user on a missing Codex.
215
+ - **Codex is a peer, not an authority.** Every output must pass your review.
216
+ - **Do not delegate trivial tasks** (<50 lines or <2 minutes of direct work). Overhead exceeds benefit.
217
+ - **Pair `full-auto` with `requireGit: true`** so Codex refuses to touch non-git directories.