Code Generation Skill
Instructions
Detect Project Framework:
- Read
.claude/project.json to identify framework and stack
- Check package.json, requirements.txt, go.mod, Cargo.toml, etc.
- Identify language version and dependencies
Select Appropriate Template:
- Match detected framework to template library
- Choose template based on code type (component, API, model, etc.)
- Adapt template to project conventions
Generate Code:
- Load template from templates/ directory
- Replace placeholders with actual values
- Apply project-specific conventions (naming, structure)
- Include proper imports and dependencies
- Add type annotations if using TypeScript/typed languages
Validate Generated Code:
- Check syntax correctness
- Verify imports are valid
- Ensure follows project patterns
- Add linting fixes if needed
Supported Frameworks
Frontend
- React (JS/TS) - JSX components, hooks, context
- Vue (2/3) - SFC templates, composition API
- Svelte - Svelte components, stores
- Angular - Components, services, modules
- Solid.js - JSX components, signals
- Qwik - Qwik components, resumability
Backend
- Node.js (Express, Fastify, Koa, NestJS)
- Python (Django, Flask, FastAPI, Pyramid)
- Go (Gin, Echo, Chi, Fiber)
- Rust (Actix, Rocket, Axum)
- Ruby (Rails, Sinatra)
- PHP (Laravel, Symfony)
- Java (Spring Boot)
- C# (.NET, ASP.NET Core)
Databases/ORMs
- Prisma, TypeORM, Sequelize (Node.js)
- SQLAlchemy, Django ORM, Tortoise (Python)
- GORM (Go)
- Diesel (Rust)
- ActiveRecord (Ruby)
- Eloquent (PHP)
Examples
Example 1: React Component Generation
Framework: React + TypeScript
Template: templates/react-ts-component.template
Output: Button.tsx with props, TypeScript types, and styles
Example 2: FastAPI Endpoint
Framework: Python + FastAPI
Template: templates/fastapi-endpoint.template
Output: router with Pydantic models and async handlers
Example 3: Go API Handler
Framework: Go + Gin
Template: templates/go-gin-handler.template
Output: handler function with request/response structs
Template Variables
All templates support these variables:
{{NAME}} - Component/function/class name
{{DESCRIPTION}} - Purpose description
{{PROPS}} - Properties/parameters
{{IMPORTS}} - Required imports
{{TYPES}} - Type definitions
{{METHODS}} - Methods/functions
{{TESTS}} - Test cases
Best Practices
- Never hardcode frameworks - Always detect from project.json
- Match existing patterns - Analyze similar files in project
- Use project conventions - Follow naming, structure, imports
- Include types - Add TypeScript/type hints when applicable
- Generate tests - Include test file alongside implementation
- Add documentation - Include JSDoc/docstrings
Template Locations
- Frontend components:
templates/frontend/
- Backend APIs:
templates/backend/
- Database models:
templates/database/
- Tests:
templates/tests/
- Configuration:
templates/config/
Purpose: Universal code generation for any framework
Used by: feature-builder, frontend-generator, backend-generator agents
1---2name: code-generation3description: Framework-agnostic code generation templates for 20+ frameworks. Use when generating code for any detected framework or stack.4---56# Code Generation Skill78## Instructions9101. **Detect Project Framework**:11 - Read `.claude/project.json` to identify framework and stack12 - Check package.json, requirements.txt, go.mod, Cargo.toml, etc.13 - Identify language version and dependencies14152. **Select Appropriate Template**:16 - Match detected framework to template library17 - Choose template based on code type (component, API, model, etc.)18 - Adapt template to project conventions19203. **Generate Code**:21 - Load template from templates/ directory22 - Replace placeholders with actual values23 - Apply project-specific conventions (naming, structure)24 - Include proper imports and dependencies25 - Add type annotations if using TypeScript/typed languages26274. **Validate Generated Code**:28 - Check syntax correctness29 - Verify imports are valid30 - Ensure follows project patterns31 - Add linting fixes if needed3233## Supported Frameworks3435### Frontend36- React (JS/TS) - JSX components, hooks, context37- Vue (2/3) - SFC templates, composition API38- Svelte - Svelte components, stores39- Angular - Components, services, modules40- Solid.js - JSX components, signals41- Qwik - Qwik components, resumability4243### Backend44- Node.js (Express, Fastify, Koa, NestJS)45- Python (Django, Flask, FastAPI, Pyramid)46- Go (Gin, Echo, Chi, Fiber)47- Rust (Actix, Rocket, Axum)48- Ruby (Rails, Sinatra)49- PHP (Laravel, Symfony)50- Java (Spring Boot)51- C# (.NET, ASP.NET Core)5253### Databases/ORMs54- Prisma, TypeORM, Sequelize (Node.js)55- SQLAlchemy, Django ORM, Tortoise (Python)56- GORM (Go)57- Diesel (Rust)58- ActiveRecord (Ruby)59- Eloquent (PHP)6061## Examples6263**Example 1: React Component Generation**64```65Framework: React + TypeScript66Template: templates/react-ts-component.template67Output: Button.tsx with props, TypeScript types, and styles68```6970**Example 2: FastAPI Endpoint**71```72Framework: Python + FastAPI73Template: templates/fastapi-endpoint.template74Output: router with Pydantic models and async handlers75```7677**Example 3: Go API Handler**78```79Framework: Go + Gin80Template: templates/go-gin-handler.template81Output: handler function with request/response structs82```8384## Template Variables8586All templates support these variables:87- `{{NAME}}` - Component/function/class name88- `{{DESCRIPTION}}` - Purpose description89- `{{PROPS}}` - Properties/parameters90- `{{IMPORTS}}` - Required imports91- `{{TYPES}}` - Type definitions92- `{{METHODS}}` - Methods/functions93- `{{TESTS}}` - Test cases9495## Best Practices9697- **Never hardcode frameworks** - Always detect from project.json98- **Match existing patterns** - Analyze similar files in project99- **Use project conventions** - Follow naming, structure, imports100- **Include types** - Add TypeScript/type hints when applicable101- **Generate tests** - Include test file alongside implementation102- **Add documentation** - Include JSDoc/docstrings103104## Template Locations105106- Frontend components: `templates/frontend/`107- Backend APIs: `templates/backend/`108- Database models: `templates/database/`109- Tests: `templates/tests/`110- Configuration: `templates/config/`111112---113114**Purpose**: Universal code generation for any framework115**Used by**: feature-builder, frontend-generator, backend-generator agents