- Home
- Skills
- Code Quality & Review
- codex grade coding
codex grade coding
A senior software engineering workflow for writing, refactoring, and testing production-grade, secure code.
$5
Works with the AI tools you already use
codex grade coding
Example session with this skill installed
Refactor the processPayment function in payment.js to handle network timeouts, validate the amount is a positive integer, and add a Jest test case for the failure scenario.
- Read your context and instructions
- Compiled the codex grade coding
I have refactored the processPayment function to include robust input validation and error handling for network failures. I also added a unit test to verify the timeout behavior.
Refactored Payment Logic and Tests
// payment.js
const axios = require('axios');
/**
* Processes a payment via the external gateway.
* @param {number} amount - Positive integer in cents.
* @param {string} token - Payment gateway token.
* @throws {Error} For invalid input or gateway timeouts.
*/
async function processPayment(amount, token) {
// Validate input: Amount must be a positive integer
if (!Number.isInteger(amount) || amount <= 0) {
throw new Error('Invalid payment amount: must be a positive integer in cents.');
}
if (!token || typeof token !== 'string') {
throw new Error('Invalid payment token.');
}
try {
const response = await axios.post('https://api.gateway.com/v1/charge', {
amount,
token
}, { timeout: 5000 }); // 5s timeout to prevent hanging threads
return response.data;
} catch (error) {
if (error.code === 'ECONNABORTED') {
throw new Error('Payment gateway timed out. Please retry.');
}
const message = error.response?.data?.message || 'Payment processing failed.';
throw new Error(message);
}
}
module.exports = { processPayment };
// __tests__/payment.test.js
const { processPayment } = require('../payment');
const axios = require('axios');
jest.mock('axios');
describe('processPayment', () => {
it('should throw an error if the network request times out', async () => {
axios.post.mockRejectedValueOnce({ code: 'ECONNABORTED' });
await expect(processPayment(1000, 'tok_test'))
.rejects
.toThrow('Payment gateway timed out. Please retry.');
});
it('should throw an error for non-integer amounts', async () => {
await expect(processPayment(10.5, 'tok_test'))
.rejects
.toThrow('Invalid payment amount');
});
});
Next steps
- Run
npm testto verify the new Jest test cases pass. - Update your
.envto ensure the gateway timeout matches your infrastructure SLAs. - Integrate the new error messages into your frontend notification service.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
The problem
Writing production code is more than just making it work. Developers often struggle with LLMs that output clever but unmaintainable hacks, introduce unnecessary dependencies, or ignore critical security and error-handling patterns.
What it does
- Analyzes existing project conventions to ensure new code integrates without architectural drift.
- Implements defensive programming patterns, including comprehensive error handling and edge-case validation.
- Performs an internal security audit to prevent injection, credential leaking, and unsafe file operations.
- Generates targeted unit and integration tests for both happy paths and failure states.
- Optimizes for simplicity and maintainability, preferring standard library solutions over bloat.
Why this beats prompting it yourself
Generic prompts often result in bloated code or "TODO" comments. This skill enforces a strict senior engineering workflow that mandates pre-implementation planning and post-implementation security reviews. It ensures every line of code is modular, testable, and production-ready by default.
Use cases
- Refactoring legacy functions into modular, testable components.
- Building new API endpoints with robust validation and security middleware.
- Writing complex business logic that requires high reliability and performance.
- Automating the generation of test suites for existing undocumented codebases.
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean 20 days ago
- Passed all security checks, Safe to install