3.9 KiB
3.9 KiB
description: Generate boilerplate code structure for new features (component, service, API endpoint, etc.)
allowed-tools: Read(), Write(), Edit(), Grep(), Glob(), Bash()
argument-hint: [type] [name]
Scaffold Command
Generate boilerplate code structure for common components.
Technology Adaptation
Configuration Source: CLAUDE.md
Consult CLAUDE.md for:
- Project Structure: Where files should be created
- Naming Conventions: How to name files and components
- Framework Patterns: Component structure for the framework
- Testing Setup: Test file structure and naming
Usage
/scaffold [type] [name]
Examples:
/scaffold component UserProfile/scaffold api user/scaffold service PaymentProcessor/scaffold model Product
Instructions
-
Parse Arguments
- $1 = type (component, api, service, model, test, etc.)
- $2 = name (PascalCase or camelCase as appropriate)
-
Read Project Patterns
- Review CLAUDE.md for:
- Project structure and conventions
- Framework in use
- Existing patterns
- Find similar existing files as templates
- Use serena MCP to analyze existing patterns
- Review CLAUDE.md for:
-
Generate Structure
- Create appropriate files per project conventions
- Follow naming from CLAUDE.md
- Include:
- Main implementation file
- Test file (if applicable)
- Interface/types (if applicable)
- Documentation comments
- Imports for common dependencies
-
Adapt to Framework
- Apply framework-specific patterns
- Use correct syntax from CLAUDE.md language
- Include framework boilerplate
- Follow project's organization
Supported Types
Adapt based on CLAUDE.md technology stack:
Frontend (React, Vue, Angular, etc.)
component: UI component with props/statepage: Page-level component with routinghook: Custom hook (React)store: State management sliceservice: Frontend service/API client
Backend (Express, Django, Rails, etc.)
api: API endpoint/route with controllerservice: Business logic servicemodel: Data model/entityrepository: Data access layermiddleware: Request middleware
Full Stack
feature: Complete feature with frontend + backendmodule: Self-contained moduletest: Test suite for existing code
Database
migration: Database migrationseed: Database seed dataschema: Database schema definition
MCP Server Usage
Serena MCP
Code Navigation:
get_symbols_overview- Find existing patterns to followfind_symbol- Locate similar components to use as templatessearch_for_pattern- Find common boilerplate patterns
Persistent Memory (stored in .serena/memories/):
- Use
write_memoryto store scaffold patterns:- "scaffold-pattern-[type]-[framework]"
- "scaffold-convention-[component-type]"
- "lesson-boilerplate-[feature]"
- Use
read_memoryto recall project scaffolding conventions - Use
list_memoriesto review scaffold patterns
Memory MCP (Knowledge Graph)
Temporary Context (in-memory, cleared after session):
- Use
create_entitiesfor components being scaffolded - Use
create_relationsto map component dependencies - Use
add_observationsto document scaffold decisions
Note: After scaffolding, store reusable patterns in Serena memory.
Context7 MCP
- Use
get-library-docsfor framework scaffolding patterns and best practices
Output Format
After scaffolding:
## Scaffolded: [Type] - [Name]
### Files Created
- `[path/to/file1]` - [Description]
- `[path/to/file2]` - [Description]
- `[path/to/file3]` - [Description]
### Next Steps
1. Implement core logic in `[main file]`
2. Add tests in `[test file]`
3. Update imports where needed
4. Run: [test command from CLAUDE.md]
### Example Usage
```[language]
[Code example showing how to use the scaffolded code]
Integration
[How this integrates with existing code]