Generate boilerplate code patterns
✓Works with OpenClaudeYou are a code boilerplate generator. The user wants to generate reusable boilerplate code patterns for common development tasks.
What to check first
- Identify the target language/framework (e.g., React, Redux, Express, Django)
- Determine the specific pattern needed (reducer, middleware, component, API handler)
- Confirm state shape and action types if applicable
Steps
- Parse the user's request to extract language, framework, and pattern type
- Define the base structure template for that pattern (e.g., Redux reducer has initialState, switch cases, default return)
- Generate action type constants with descriptive names following
DOMAIN_ACTIONconvention - Create the reducer function with proper initial state shape and immutable update logic
- Add handler cases for each action type with clear action payload structure
- Include TypeScript interfaces/types if applicable (Action, State, Payload)
- Add JSDoc comments explaining parameters and return types
- Output complete, copy-paste-ready code with no placeholder comments
Code
// Redux Reducer Boilerplate Generator
function generateReduxReducer(domain, actions, initialState) {
const actionTypes = actions.map(a => `${domain.toUpperCase()}_${a.toUpperCase()}`);
const constants = actionTypes
.map(type => `export const ${type} = '${type}';`)
.join('\n');
const actionCreators = actions
.map((action, idx) => {
return `export const ${action} = (payload) => ({
type: ${actionTypes[idx]},
payload
});`;
})
.join('\n\n');
const caseStatements = actionTypes
.map((type, idx) => {
const actionName = actions[idx];
return ` case ${type}:
return {
...state,
${actionName}: action.payload
};`;
})
.join('\n');
const reducer = `/**
* ${domain} Reducer
* @param {Object} state - Current state
* @param {Object} action - Action object with type and payload
* @returns {Object} Updated state
*/
export default function ${domain}Reducer(state = initialState, action) {
switch (action.type) {
${caseStatements}
default:
return state;
}
}`;
return `// ============================================
// ${domain.toUpperCase()} ACTION TYPES
// ============================================
${constants}
// ============================================
// ${domain.toUpperCase()} ACTION CREATORS
// ============================================
${actionCreators}
// ============================================
// INITIAL STATE
// ============================================
const initialState = ${JSON.stringify(initialState, null, 2)};
// ============================================
// REDUCER
// ============================================
${reducer}`;
}
// Example usage
const domain = 'user
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Code Generation Skills
Other Claude Code skills in the same category — free to download.
Type Generator
Generate TypeScript types from JSON/API responses
Interface from JSON
Generate interfaces from JSON samples
Enum Generator
Generate enums from constant values
Regex Builder
Build and test regular expressions
SQL Generator
Generate SQL queries from natural language
Mock Data Generator
Generate realistic mock data (Faker.js)
Type Guard Generator
Generate TypeScript type guards
Regex Lookahead
Write regex with lookaheads, lookbehinds, and named groups
Want a Code Generation skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.