Files
FoundryVTT/.claude/commands/scaffold.md
2025-11-06 14:04:48 +01:00

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

  1. Parse Arguments

    • $1 = type (component, api, service, model, test, etc.)
    • $2 = name (PascalCase or camelCase as appropriate)
  2. 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
  3. 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
  4. 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/state
  • page: Page-level component with routing
  • hook: Custom hook (React)
  • store: State management slice
  • service: Frontend service/API client

Backend (Express, Django, Rails, etc.)

  • api: API endpoint/route with controller
  • service: Business logic service
  • model: Data model/entity
  • repository: Data access layer
  • middleware: Request middleware

Full Stack

  • feature: Complete feature with frontend + backend
  • module: Self-contained module
  • test: Test suite for existing code

Database

  • migration: Database migration
  • seed: Database seed data
  • schema: Database schema definition

MCP Server Usage

Serena MCP

Code Navigation:

  • get_symbols_overview - Find existing patterns to follow
  • find_symbol - Locate similar components to use as templates
  • search_for_pattern - Find common boilerplate patterns

Persistent Memory (stored in .serena/memories/):

  • Use write_memory to store scaffold patterns:
    • "scaffold-pattern-[type]-[framework]"
    • "scaffold-convention-[component-type]"
    • "lesson-boilerplate-[feature]"
  • Use read_memory to recall project scaffolding conventions
  • Use list_memories to review scaffold patterns

Memory MCP (Knowledge Graph)

Temporary Context (in-memory, cleared after session):

  • Use create_entities for components being scaffolded
  • Use create_relations to map component dependencies
  • Use add_observations to document scaffold decisions

Note: After scaffolding, store reusable patterns in Serena memory.

Context7 MCP

  • Use get-library-docs for 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]