skill-codex 0.2.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.
- package/LICENSE +21 -0
- package/README.md +202 -0
- package/commands/codex-consult.md +36 -0
- package/commands/codex-do.md +44 -0
- package/commands/codex-review.md +35 -0
- package/dist/bin/skill-codex.js +467 -0
- package/dist/bin/skill-codex.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +722 -0
- package/dist/index.js.map +1 -0
- package/hooks/post-tool-use-review.ps1 +50 -0
- package/hooks/post-tool-use-review.sh +49 -0
- package/package.json +81 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Arystos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# skill-codex
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
[](https://ko-fi.com/arystos)
|
|
11
|
+
|
|
12
|
+
A cross-platform [Claude Code](https://code.claude.com) skill that integrates [OpenAI Codex CLI](https://github.com/openai/codex) for code review, task delegation, and consultation. Uses your existing Codex subscription -- no API key required.
|
|
13
|
+
|
|
14
|
+
## Why?
|
|
15
|
+
|
|
16
|
+
Claude Code and Codex CLI have different strengths. Claude excels at reasoning, architecture, and complex refactors. Codex is fast, thorough, and great at focused execution and review. **skill-codex** lets them work together from a single terminal -- no second window, no copy-paste, no context loss.
|
|
17
|
+
|
|
18
|
+
* **`/codex-review`** -- Have Codex review your current changes as a second reviewer
|
|
19
|
+
* **`/codex-do`** -- Delegate well-scoped implementation tasks to Codex
|
|
20
|
+
* **`/codex-consult`** -- Get a second opinion on architecture or design decisions
|
|
21
|
+
* **Auto-review hook** -- Smart PostToolUse hook suggests review after significant changes
|
|
22
|
+
* **Subscription-first** -- Works with `codex login`, no `OPENAI_API_KEY` needed
|
|
23
|
+
* **Edge case handling** -- Retry logic, timeout, anti-recursion, lock files, pre-flight checks
|
|
24
|
+
|
|
25
|
+
## Prerequisites
|
|
26
|
+
|
|
27
|
+
* [Node.js](https://nodejs.org) >= 18
|
|
28
|
+
* [Claude Code](https://code.claude.com) installed and authenticated
|
|
29
|
+
* [Codex CLI](https://github.com/openai/codex) installed and logged in (`codex login`)
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```shell
|
|
34
|
+
# 1. Install and configure everything in one command
|
|
35
|
+
npx skill-codex setup
|
|
36
|
+
|
|
37
|
+
# 2. Restart Claude Code to load the MCP server
|
|
38
|
+
|
|
39
|
+
# 3. Use the commands in any project
|
|
40
|
+
/codex-review # Review uncommitted changes
|
|
41
|
+
/codex-do "write tests" # Delegate a task to Codex
|
|
42
|
+
/codex-consult "approach?" # Get a second opinion
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The setup command:
|
|
46
|
+
1. Registers the MCP server in your Claude Code config (`~/.claude.json`)
|
|
47
|
+
2. Installs slash commands globally (`~/.claude/commands/`)
|
|
48
|
+
3. Configures the auto-review PostToolUse hook
|
|
49
|
+
4. Verifies everything works
|
|
50
|
+
|
|
51
|
+
> **Tip:** Add `.skill-codex.lock` to your `.gitignore`
|
|
52
|
+
|
|
53
|
+
## How It Works
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
You in Claude Code
|
|
57
|
+
|
|
|
58
|
+
|-- /codex-review --> MCP tool --> codex exec (read-only) --> review findings
|
|
59
|
+
|-- /codex-do "task" --> MCP tool --> codex exec --full-auto --> reviewed output
|
|
60
|
+
+-- /codex-consult "q" --> MCP tool --> codex exec (read-only) --> synthesized opinion
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The MCP server spawns `codex exec` as a subprocess, using your logged-in Codex session. Claude sees the output and critically evaluates it -- **Codex is treated as a peer, not an authority**.
|
|
64
|
+
|
|
65
|
+
### Auto-review
|
|
66
|
+
|
|
67
|
+
After significant code changes (3+ files, 100+ lines, security-related paths), the PostToolUse hook suggests running `/codex-review`. Trivial changes (docs-only, < 5 lines, whitespace) are skipped to preserve your Codex quota.
|
|
68
|
+
|
|
69
|
+
### Example: `/codex-review`
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
> /codex-review
|
|
73
|
+
|
|
74
|
+
Reviewing uncommitted changes (3 files, ~85 lines)...
|
|
75
|
+
|
|
76
|
+
Codex found 2 issues:
|
|
77
|
+
|
|
78
|
+
CRITICAL — src/auth/login.ts:42
|
|
79
|
+
Password comparison uses == instead of timing-safe comparison.
|
|
80
|
+
Claude's assessment: Agree. Use crypto.timingSafeEqual() instead.
|
|
81
|
+
|
|
82
|
+
MEDIUM — src/api/routes.ts:18
|
|
83
|
+
Missing rate limiting on login endpoint.
|
|
84
|
+
Claude's assessment: Agree. Add rate limiter middleware.
|
|
85
|
+
|
|
86
|
+
Shall I fix these issues?
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Configuration
|
|
90
|
+
|
|
91
|
+
Environment variables (all optional):
|
|
92
|
+
|
|
93
|
+
| Variable | Default | Description |
|
|
94
|
+
|----------|---------|-------------|
|
|
95
|
+
| `SKILL_CODEX_TIMEOUT_MS` | `600000` (10 min) | Subprocess timeout |
|
|
96
|
+
| `SKILL_CODEX_MAX_RETRIES` | `3` | Retry count for transient errors |
|
|
97
|
+
| `SKILL_CODEX_DEBUG` | -- | Enable debug logging to stderr |
|
|
98
|
+
|
|
99
|
+
### Smart Filter Thresholds
|
|
100
|
+
|
|
101
|
+
| Condition | Action | Rationale |
|
|
102
|
+
|-----------|--------|-----------|
|
|
103
|
+
| < 5 lines changed | Skip | Not worth the Codex call |
|
|
104
|
+
| All files are `.md`/`.txt`/`.rst` | Skip | Documentation-only |
|
|
105
|
+
| Whitespace or import-only diff | Skip | Formatting change |
|
|
106
|
+
| Path contains `auth`/`security`/`crypto` | **Force review** | Security-sensitive |
|
|
107
|
+
| > 100 lines changed | **Force review** | High-impact change |
|
|
108
|
+
| > 3 files changed | **Force review** | Cross-cutting change |
|
|
109
|
+
|
|
110
|
+
## Edge Cases Handled
|
|
111
|
+
|
|
112
|
+
| Scenario | What Happens |
|
|
113
|
+
|----------|-------------|
|
|
114
|
+
| Codex not installed | Clear error with install instructions |
|
|
115
|
+
| Auth expired | Advises `codex login`, no retry |
|
|
116
|
+
| Network down | Retries 3x with exponential backoff |
|
|
117
|
+
| Rate limited (429) | Retries with backoff + jitter |
|
|
118
|
+
| Codex hangs | Killed after timeout (SIGTERM then SIGKILL) |
|
|
119
|
+
| Concurrent runs | Lock file prevents conflicts (stale after 15min) |
|
|
120
|
+
| Recursive calls | `SKILL_CODEX_DEPTH` limit prevents infinite loops |
|
|
121
|
+
| Trivial changes | Smart filter skips auto-review |
|
|
122
|
+
| Empty Codex output | Retries once, then reports clearly |
|
|
123
|
+
|
|
124
|
+
## Project Structure
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
skill-codex/
|
|
128
|
+
|-- src/
|
|
129
|
+
| |-- index.ts # MCP server entry point
|
|
130
|
+
| |-- server.ts # MCP server + tool registration
|
|
131
|
+
| |-- tools/codex-exec.ts # codex_exec tool handler
|
|
132
|
+
| |-- runner/ # exec-runner, retry, timeout, output parser
|
|
133
|
+
| |-- guards/ # pre-flight checks (binary, auth, git, recursion, lock)
|
|
134
|
+
| |-- filter/ # smart diff filter for auto-review
|
|
135
|
+
| |-- lock/ # lock file with stale detection
|
|
136
|
+
| |-- errors/ # typed error classes
|
|
137
|
+
| |-- config/ # constants, paths, platform utils
|
|
138
|
+
| +-- util/ # platform detection, truncation
|
|
139
|
+
|-- commands/
|
|
140
|
+
| |-- codex-review.md # /codex-review slash command
|
|
141
|
+
| |-- codex-do.md # /codex-do slash command
|
|
142
|
+
| +-- codex-consult.md # /codex-consult slash command
|
|
143
|
+
|-- hooks/
|
|
144
|
+
| |-- post-tool-use-review.sh # Auto-review hook (macOS/Linux)
|
|
145
|
+
| +-- post-tool-use-review.ps1 # Auto-review hook (Windows)
|
|
146
|
+
|-- setup/ # npx skill-codex setup installer
|
|
147
|
+
|-- bin/ # CLI entry point
|
|
148
|
+
+-- __tests__/ # vitest test suite
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Uninstall
|
|
152
|
+
|
|
153
|
+
```shell
|
|
154
|
+
npx skill-codex uninstall
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Development
|
|
158
|
+
|
|
159
|
+
```shell
|
|
160
|
+
git clone https://github.com/Arystos/skill-codex.git
|
|
161
|
+
cd skill-codex
|
|
162
|
+
npm install
|
|
163
|
+
npm run build
|
|
164
|
+
npm test
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Troubleshooting
|
|
168
|
+
|
|
169
|
+
**Setup says "Hook script not found"**
|
|
170
|
+
Run `npm run build` first, then `npx skill-codex setup` again. The hook scripts live in the package root, not in `dist/`.
|
|
171
|
+
|
|
172
|
+
**`/codex-review` says "Unknown tool: codex_exec"**
|
|
173
|
+
Restart Claude Code after running setup. The MCP server only loads on startup.
|
|
174
|
+
|
|
175
|
+
**Codex keeps timing out**
|
|
176
|
+
Increase the timeout: `export SKILL_CODEX_TIMEOUT_MS=1200000` (20 min). Large codebases can take longer.
|
|
177
|
+
|
|
178
|
+
**"Auth expired" but Codex works in another terminal**
|
|
179
|
+
The MCP server runs in its own process. Run `codex login` and restart Claude Code.
|
|
180
|
+
|
|
181
|
+
**Lock file blocking runs**
|
|
182
|
+
If a previous run crashed, a stale `.skill-codex.lock` may remain. It auto-cleans after 15 minutes, or delete it manually.
|
|
183
|
+
|
|
184
|
+
## Inspired By
|
|
185
|
+
|
|
186
|
+
* [Dunqing/claude-codex-bridge](https://github.com/Dunqing/claude-codex-bridge) -- retry logic, anti-recursion, output parsing
|
|
187
|
+
* [EpocheDrift/claude-codex-skill](https://github.com/EpocheDrift/claude-codex-skill) -- subscription-first, delegation heuristics
|
|
188
|
+
* [incadawr/claude-codex-skill](https://github.com/incadawr/claude-codex-skill) -- MCP server approach, auto-triggers
|
|
189
|
+
|
|
190
|
+
## Contributing
|
|
191
|
+
|
|
192
|
+
Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
193
|
+
|
|
194
|
+
## Support
|
|
195
|
+
|
|
196
|
+
If you find this useful, consider supporting the project:
|
|
197
|
+
|
|
198
|
+
[](https://ko-fi.com/arystos)
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
MIT
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Consult Codex for a Second Opinion
|
|
2
|
+
|
|
3
|
+
Get Codex's perspective on a technical question, plan, or approach.
|
|
4
|
+
|
|
5
|
+
## Instructions
|
|
6
|
+
|
|
7
|
+
You are consulting Codex for a second opinion. This is read-only — no files will be modified.
|
|
8
|
+
|
|
9
|
+
1. **Parse the question** from `$ARGUMENTS`. This could be:
|
|
10
|
+
- A technical question about the codebase
|
|
11
|
+
- A plan you want validated before implementing
|
|
12
|
+
- An architecture decision you want a second perspective on
|
|
13
|
+
- A debugging hypothesis you want challenged
|
|
14
|
+
- A technology choice comparison
|
|
15
|
+
|
|
16
|
+
2. **Prepare a focused prompt** for Codex. Include:
|
|
17
|
+
- The specific question or plan to evaluate
|
|
18
|
+
- Relevant context: file paths, code snippets, constraints
|
|
19
|
+
- What kind of feedback you want (validation, alternatives, risks, tradeoffs)
|
|
20
|
+
|
|
21
|
+
3. **Call the `codex_exec` MCP tool** with:
|
|
22
|
+
- `prompt`: "Provide your analysis and recommendation on the following question. Consider tradeoffs, alternatives, and potential risks. Be specific and cite concrete examples where possible.\n\n<question with context>"
|
|
23
|
+
- `mode`: "exec"
|
|
24
|
+
|
|
25
|
+
4. **Synthesize both perspectives** for the user:
|
|
26
|
+
- Present Codex's analysis
|
|
27
|
+
- Provide your own independent analysis
|
|
28
|
+
- Where you agree and why
|
|
29
|
+
- Where you disagree and why (with evidence)
|
|
30
|
+
- Your recommended path forward with reasoning
|
|
31
|
+
|
|
32
|
+
## Important
|
|
33
|
+
|
|
34
|
+
- Codex runs in **read-only mode** — it cannot modify files
|
|
35
|
+
- This is a **consultation, not a delegation** — the final decision rationale comes from this conversation
|
|
36
|
+
- If you and Codex strongly disagree, present both arguments fairly and let the user decide
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Delegate Task to Codex
|
|
2
|
+
|
|
3
|
+
Delegate a well-scoped implementation task to Codex.
|
|
4
|
+
|
|
5
|
+
## Instructions
|
|
6
|
+
|
|
7
|
+
You are delegating an implementation task to Codex. Follow these steps:
|
|
8
|
+
|
|
9
|
+
1. **Parse the task** from `$ARGUMENTS`. If the argument is vague or missing, ask the user to be more specific before proceeding.
|
|
10
|
+
|
|
11
|
+
2. **Evaluate if the task is suitable for delegation**:
|
|
12
|
+
- **Good for Codex**: repetitive bulk changes, boilerplate generation, test writing for existing code, migration scripts, file format conversions, well-defined single-file edits
|
|
13
|
+
- **Keep for yourself**: architectural decisions, cross-module refactoring, tasks requiring deep conversation context, ambiguous requirements, tasks under 50 lines
|
|
14
|
+
- If the task is poorly scoped, explain why and suggest how to break it down.
|
|
15
|
+
|
|
16
|
+
3. **Prepare a precise, self-contained prompt** for Codex. Include:
|
|
17
|
+
- Exact file paths to create or modify
|
|
18
|
+
- The specific change required with examples if helpful
|
|
19
|
+
- Constraints (language, framework, coding style, naming conventions)
|
|
20
|
+
- What "done" looks like
|
|
21
|
+
|
|
22
|
+
4. **Call the `codex_exec` MCP tool** with:
|
|
23
|
+
- `prompt`: the prepared prompt
|
|
24
|
+
- `mode`: "full-auto"
|
|
25
|
+
- `requireGit`: true
|
|
26
|
+
|
|
27
|
+
5. **Review Codex's output critically**:
|
|
28
|
+
- Run `git diff` to see exactly what Codex changed
|
|
29
|
+
- Check for introduced bugs, regressions, or style violations
|
|
30
|
+
- Verify it matches the requested changes
|
|
31
|
+
- Verify it doesn't modify files outside the requested scope
|
|
32
|
+
|
|
33
|
+
6. **Present the result** with your assessment:
|
|
34
|
+
- What was done correctly
|
|
35
|
+
- What needs adjustment
|
|
36
|
+
- Apply changes only if they pass your review
|
|
37
|
+
- If issues found, offer to fix them yourself or re-delegate with refined instructions
|
|
38
|
+
|
|
39
|
+
## Important
|
|
40
|
+
|
|
41
|
+
- Codex runs in **full-auto mode** — it CAN modify files in the workspace
|
|
42
|
+
- Always `git diff` after Codex runs to verify what changed
|
|
43
|
+
- Codex is a **peer, not an authority** — review all output before accepting
|
|
44
|
+
- For complex multi-file tasks, consider doing it yourself instead
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Codex Code Review
|
|
2
|
+
|
|
3
|
+
Review the current changes using Codex as a second reviewer.
|
|
4
|
+
|
|
5
|
+
## Instructions
|
|
6
|
+
|
|
7
|
+
You are invoking Codex for a second-opinion code review. Follow these steps:
|
|
8
|
+
|
|
9
|
+
1. **Determine what to review** based on `$ARGUMENTS`:
|
|
10
|
+
- If empty or "uncommitted": get unstaged changes via `git diff`. If empty, try staged changes via `git diff --cached`. If both empty, inform the user there are no changes to review.
|
|
11
|
+
- If it looks like a branch name: get changes via `git diff <branch>...HEAD`
|
|
12
|
+
- If it looks like a commit SHA: get changes via `git show <sha>`
|
|
13
|
+
|
|
14
|
+
2. **Check the diff size**:
|
|
15
|
+
- If the diff is empty, tell the user and stop.
|
|
16
|
+
- If the diff exceeds 50,000 characters, summarize it first and warn that Codex will see a truncated version.
|
|
17
|
+
|
|
18
|
+
3. **Call the `codex_exec` MCP tool** with:
|
|
19
|
+
- `prompt`: "Review the following code changes. For each finding, specify: severity (CRITICAL/HIGH/MEDIUM/LOW), file and line, description, and suggested fix.\n\nFocus on: bugs, security issues, performance problems, error handling gaps, and readability.\n\n```diff\n<the diff>\n```"
|
|
20
|
+
- `mode`: "exec"
|
|
21
|
+
- `requireGit`: true
|
|
22
|
+
|
|
23
|
+
4. **Present findings** to the user:
|
|
24
|
+
- Group by severity (CRITICAL first)
|
|
25
|
+
- For each finding, add your own assessment: agree, disagree, or nuance
|
|
26
|
+
- Note anything Codex missed that you think is important
|
|
27
|
+
- Summarize actionable items at the end
|
|
28
|
+
|
|
29
|
+
5. **If Codex found issues**, offer to fix them.
|
|
30
|
+
|
|
31
|
+
## Important
|
|
32
|
+
|
|
33
|
+
- Codex runs in **read-only mode** — it cannot modify files
|
|
34
|
+
- Codex is a **peer, not an authority** — evaluate each finding critically
|
|
35
|
+
- If the MCP tool returns an error, explain what happened and suggest remediation
|