- Home
- Skills
- Code Quality & Review
- codex grade coding
codex grade coding
by Skills Pro
A senior software engineering workflow for writing, refactoring, and testing production-grade, secure code.
$5
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.
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.
Cannot verify code execution or deployment status unless the environment provides active runtime tools. Requires access to existing files to maintain architectural consistency.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 3 months ago
Permissions
What's inside
Frequently Asked Questions
New in Code Quality & Review
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Code Quality & Review.