Universal code generator - clones your existing code style exactly
View on GitHubSelect agents to install to:
npx add-skill https://github.com/jhlee0409/claude-plugins/blob/main/plugins/oas/skills/code-generator/SKILL.md -a claude-code --skill code-generatorInstallation paths:
.claude/skills/code-generator/# Code Generator
Generate API code that perfectly matches your project's existing patterns.
**Core Principle:** Your code style is the template.
---
## EXECUTION INSTRUCTIONS
When this skill is invoked, Claude MUST perform these steps in order:
### Step 1: Receive Inputs
This skill requires:
1. **Detected patterns** from `pattern-detector` skill
2. **Parsed endpoints** from `openapi-parser` skill
3. **Target tag** or list of endpoints to generate
Verify all inputs are present before proceeding.
### Step 2: Load Sample Code
1. Read the sample files from detected patterns:
- `samples.api` → API function patterns
- `samples.types` → Type definition patterns
- `samples.hooks` → Hook patterns (if applicable)
2. For each sample, extract:
- Import statements
- Export patterns
- Function/type structure
- Naming conventions
- Code style (quotes, semicolons, indentation)
### Step 3: Generate File Paths
Based on detected structure pattern, generate target file paths:
**FSD Pattern:**
```
src/entities/{tag}/
├── api/
│ ├── {tag}-api.ts
│ ├── {tag}-api-paths.ts
│ └── {tag}-queries.ts
└── model/
└── {tag}-types.ts
```
**Feature-based Pattern:**
```
src/features/{tag}/
├── api.ts
├── hooks.ts
└── types.ts
```
**Flat Pattern:**
```
src/api/{tag}/
├── api.ts
├── hooks.ts
└── types.ts
```
### Step 4: Generate Types
For each schema used by target endpoints:
1. **Determine type style** from sample (interface vs type)
2. **Generate TypeScript definition:**
```typescript
// If sample uses interface:
export interface User {
id: string
name: string
email?: string // optional if not in required array
}
// If sample uses type:
export type User = {
id: string
name: string
email?: string
}
```
3. **Generate Request/Response types:**
- Follow naming convention from sample
- Examples: `GetUserRequest`, `CreateUserRequest`, `UserResponse`
### Step 5: Generate Path Constants
Clone the path constant pattern from sample:
`