Claude Code integrates with OpenAI Codex CLI for advanced code analysis, refactoring, and automated editing. Benefits developers and operations teams by automating code improvements and reducing manual effort. Connects to OpenAI Codex CLI for code manipulation.
git clone https://github.com/sypsyp97/claude-skill-codex.gitClaude Code integrates with OpenAI Codex CLI for advanced code analysis, refactoring, and automated editing. Benefits developers and operations teams by automating code improvements and reducing manual effort. Connects to OpenAI Codex CLI for code manipulation.
1. **Install Dependencies:** Ensure you have `claude-skill-codex` enabled and OpenAI Codex CLI installed (`npm install -g @openai/codex-cli`). Verify installation with `codex --version`. 2. **Scope Your Analysis:** Navigate to your project root in the terminal. Decide whether to analyze the entire codebase or focus on a specific directory/file (e.g., `src/` or `routes.js`). 3. **Run Initial Analysis:** Execute a broad scan to identify issues: ```bash codex analyze ./ --output issues.json ``` Review `issues.json` to prioritize problems by severity and impact. 4. **Targeted Refactoring:** Use the prompt template to generate a focused refactor command. For example, to optimize database queries: ```bash codex refactor ./src --focus "database performance" --dry-run ``` Remove `--dry-run` to apply changes once validated. 5. **Validate Changes:** Run your test suite (`npm test` or `pytest`) and performance benchmarks (e.g., `autocannon -c 100 -d 5 http://localhost:3000/api/products`). Commit changes only after green tests. **Tips:** - Use `--focus` to narrow scope (e.g., "security vulnerabilities" or "code style"). - For large codebases, start with `--max-files 50` to avoid overwhelming results. - Save Codex CLI commands in a `codex-tasks.sh` script for repeatability.
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/sypsyp97/claude-skill-codexCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Use claude-skill-codex to analyze and refactor the following codebase: [CODEBASE_PATH]. Focus on [SPECIFIC_ISSUES: e.g., performance bottlenecks, security vulnerabilities, or code style violations]. Provide a detailed report with: 1) Identified issues ranked by severity, 2) Suggested fixes with code snippets, 3) Estimated time savings for each fix, and 4) A prioritized action plan. Run the refactoring using OpenAI Codex CLI with the command: `codex refactor [CODEBASE_PATH] --focus [SPECIFIC_ISSUES]` and include the output in your response.
### Code Analysis & Refactoring Report
**Project:** `ecommerce-backend` (Node.js/Express)
**Scope:** Performance optimization for `/api/products` endpoint
#### 1. Identified Issues (Ranked by Severity)
- **Critical (P0):** N+1 query problem in `ProductController.getProducts()`. The current implementation makes 100+ database calls for a single request when fetching products with reviews. Estimated impact: 85% slower response time under load.
- **High (P1):** Unused middleware `authMiddleware` in `routes.js` adds 15ms overhead per request. No authentication is actually enforced.
- **Medium (P2):** Inconsistent error handling in `errorHandler.js`—some routes return 500, others return 404 for the same error type.
#### 2. Suggested Fixes with Code Snippets
**P0 Fix (N+1 Query):**
```javascript
// Before: Separate calls for products and reviews
const products = await Product.find();
const reviews = await Review.find({ productId: { $in: products.map(p => p._id) } });
// After: Single optimized query with population
const products = await Product.find().populate({
path: 'reviews',
options: { sort: { createdAt: -1 }, limit: 5 }
});
```
**P1 Fix (Unused Middleware):**
```diff
- app.use('/api/products', authMiddleware, productRoutes);
+ app.use('/api/products', productRoutes);
```
**P2 Fix (Error Handling):**
```javascript
// Standardized error response
const handleError = (err, req, res, next) => {
console.error(err);
res.status(400).json({
error: 'Validation failed',
details: err.message
});
};
```
#### 3. Estimated Time Savings
- P0 Fix: Reduces response time from 1.2s to 180ms (85% improvement). Manual fix would take 4-6 hours; Codex completes in 2 minutes.
- P1 Fix: Saves 15ms per request. Manual fix: 30 minutes; Codex: 30 seconds.
- P2 Fix: Reduces debugging time by 2 hours/month. Manual fix: 1 hour; Codex: 1 minute.
#### 4. Prioritized Action Plan
1. **Immediate (Today):** Deploy P0 fix using Codex CLI:
```bash
codex refactor ./src/controllers/ProductController.js --focus "N+1 query"
```
2. **This Week:** Address P1 and P2 fixes. Test with `npm run test:performance` and monitor `/api/products` latency in New Relic.
3. **Next Sprint:** Run full Codex analysis on entire codebase with:
```bash
codex analyze ./ --output report.json
```
#### Codex CLI Output (P0 Fix Applied)
```
Refactoring 1 file...
✅ Optimized ProductController.getProducts() to use population (saved 1.02s per request)
✨ Applied 1 change in 1 file
```
**Next Steps:** Commit changes, run integration tests, and deploy to staging for validation.Advanced foundation models via API and ChatGPT
AI assistant built for thoughtful, nuanced conversation
IronCalc is a spreadsheet engine and ecosystem
Customer feedback management made simple
Enterprise workflow automation and service management platform
Automate your spreadsheet tasks with AI power
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan