stacks-scaffolding

$npx mdskill add stacksjs/stacks/stacks-scaffolding

Generate new code using Stacks buddy make commands and STX scaffolding utilities.

  • Creates components, pages, stores, layouts, and project templates via CLI.
  • Depends on buddy CLI commands and the @stacksjs/stx scaffolding module.
  • Selects appropriate template or generator based on the requested artifact type.
  • Outputs generated files directly into the project structure or runs the command.

SKILL.md

.github/skills/stacks-scaffoldingView on GitHub ↗
---
name: stacks-scaffolding
description: Use when generating new code with Stacks — buddy make commands, project scaffolding, component/page/store/layout generation, or project templates. Covers buddy make:* commands and STX scaffolding utilities.
license: MIT
compatibility: Bun >= 1.3.0, TypeScript
allowed-tools: Read Edit Write Bash Grep Glob
---

# Stacks Scaffolding

## Key Paths
- Buddy commands: `storage/framework/core/buddy/src/commands/make.ts`
- Default templates: `storage/framework/defaults/`
- STX scaffolding: `@stacksjs/stx` (scaffolding module)

## CLI Make Commands

```bash
buddy make:component <name>     # Create a new STX component
buddy make:function <name>      # Create a new function/composable
buddy make:migration <name>     # Create a new database migration
buddy make:notification <name>  # Create a notification class
buddy make:factory <name>       # Create a model factory
buddy make:lang <name>          # Create a language/locale file
buddy make:stack <name>         # Create a new stack
buddy extension:init            # Create a Chrome + Firefox + Safari extension
buddy extension:init --target safari --bundle-id com.example.Extension
```

## STX Scaffolding API

```typescript
import { createProject, addComponent, addPage, addStore, addLayout } from '@stacksjs/stx'
```

### Create Project

```typescript
async function createProject(name: string, options?: CreateProjectOptions): Promise<ScaffoldResult>

interface CreateProjectOptions {
  template?: 'default' | 'minimal' | 'full' | 'blog' | 'dashboard' | 'landing'
  skipGit?: boolean
  skipInstall?: boolean
  packageManager?: 'bun' | 'npm' | 'pnpm' | 'yarn'
  typescript?: boolean
  examples?: boolean
  pwa?: boolean
  tailwind?: boolean
}
```

### Add Component

```typescript
async function addComponent(name: string, options?: AddComponentOptions): Promise<ScaffoldResult>

interface AddComponentOptions {
  dir?: string       // Custom directory (default: componentsDir)
  props?: boolean    // Include props section
  styles?: boolean   // Include style block
  script?: boolean   // Include script block
  force?: boolean    // Overwrite existing
}
```

### Add Page

```typescript
async function addPage(name: string, options?: AddPageOptions): Promise<ScaffoldResult>

interface AddPageOptions {
  dir?: string       // Custom directory
  layout?: string    // Layout to use
  dynamic?: boolean  // Dynamic route parameter
  loader?: boolean   // Include data loader
  force?: boolean
}
```

### Add Store

```typescript
async function addStore(name: string, options?: AddStoreOptions): Promise<ScaffoldResult>

interface AddStoreOptions {
  dir?: string
  persist?: boolean   // Persist state to storage
  actions?: boolean   // Include action methods
  force?: boolean
}
```

### Add Layout

```typescript
async function addLayout(name: string, options?: AddLayoutOptions): Promise<ScaffoldResult>

interface AddLayoutOptions {
  dir?: string
  nav?: boolean      // Include navigation
  footer?: boolean   // Include footer
  force?: boolean
}
```

### Scaffold Result

```typescript
interface ScaffoldResult {
  success: boolean
  message: string
  files: string[]     // Created file paths
  errors: string[]
}
```

## Project Templates

| Template | Description |
|----------|-------------|
| `default` | Standard project with common features |
| `minimal` | Bare minimum setup |
| `full` | All features enabled |
| `blog` | Blog-focused with CMS |
| `dashboard` | Admin dashboard |
| `landing` | Marketing landing page |

## Generated File Locations

| Type | Location |
|------|----------|
| Components | `resources/components/` |
| Functions | `resources/functions/` |
| Migrations | `database/migrations/` |
| Notifications | `app/Notifications/` |
| Language files | `locales/` |
| Layouts | `resources/layouts/` |
| Pages | `resources/views/` |
| Stores | `resources/stores/` |
| Partials | `resources/partials/` |

Browser-extension scaffolding also follows this resource layout: popup pages
live in `resources/views/`, browser scripts in `resources/scripts/`, and shared
includes in `resources/partials/`. Safari scaffolding creates the Xcode
container app alongside the web-extension starter.

## Default Templates

Templates for generated code are in `storage/framework/defaults/`:
- `defaults/components/` — component templates
- `defaults/models/` — model templates
- `defaults/app/Middleware/` — middleware templates
- `defaults/layouts/` — layout templates
- `defaults/views/` — view templates

## Gotchas
- **Always use make commands** — ensures consistent file structure and naming
- **Templates are customizable** — modify files in `storage/framework/defaults/` to change scaffolding output
- **Run pickier after generating** — `bunx --bun pickier . --fix` to format generated code
- **`force` flag overwrites** — without it, existing files are not overwritten
- **STX scaffolding vs buddy make** — `addComponent()` is the programmatic API, `buddy make:component` is the CLI equivalent

More from stacksjs/stacks

SkillDescription
stacks-actionsUse when working with Stacks server actions — creating actions in app/Actions/, auto-generated API actions from the useApi model trait, the 80+ default framework actions (auth, dashboard, commerce, content, deployment, jobs), action request/response handling, or action registration. Covers @stacksjs/actions and storage/framework/defaults/actions/.
stacks-aiUse when integrating AI capabilities into a Stacks application — using Anthropic/OpenAI/Ollama/AWS Bedrock drivers, image generation (DALL-E), vision analysis, RAG/vector search, embeddings, MCP (Model Context Protocol) clients, text summarization, sentiment analysis, content classification, personalization, or the buddy AI assistant. Covers @stacksjs/ai and config/ai.ts.
stacks-aliasUse when working with path aliases in a Stacks project — import resolution, module aliasing, or debugging import paths. Covers @stacksjs/alias which defines 260+ path mappings for the entire framework.
stacks-analyticsUse when adding analytics to a Stacks application — configuring Fathom or self-hosted analytics, generating tracking scripts, privacy-friendly analytics setup, or the analytics configuration. Covers @stacksjs/analytics and config/analytics.ts.
stacks-apiUse when building, modifying, or debugging API endpoints in a Stacks application — defining routes, handling requests, API middleware, working with the API server, HTTP client (fetcher), API resources, or OpenAPI generation. Covers both @stacksjs/api utilities and the stacks-api server implementation.
stacks-arraysUse when working with array utilities in Stacks — statistical operations (average, median, mode, standard deviation, z-score, percentile, covariance), array manipulation (unique, flatten, partition, shuffle, sample, move), containment checks, or the Arr facade. Covers @stacksjs/arrays.
stacks-authUse when implementing authentication, authorization, passkeys, TOTP/2FA, RBAC, gates, policies, session auth, token management, email verification, password resets, or rate limiting in a Stacks application. Covers the @stacksjs/auth package, config/auth.ts, app/Gates.ts, and app/Middleware/.
stacks-auto-importsUse when working with the Stacks auto-import system — understanding how browser and server auto-imports work, configuring auto-imported functions/models/composables, the auto-import manifests, type generation, or how globals are injected. Covers the auto-import pipeline at storage/framework/auto-imports/.
stacks-brandkitUse when defining or exploring a brand identity for a Stacks project and you want premium brand-kit REFERENCE IMAGES first - logo directions, palettes, typography specimens, identity boards, and application/mockup decks. Generates IMAGES ONLY, never code. Trained for minimalist, cinematic, editorial, dark-tech, luxury, cultural, security, gaming, developer-tool, and consumer-app brand systems with intentional logo concepting, sparse type, strong symbolic meaning, and disciplined palettes a coding step can build against.
stacks-browseUse for headless browser QA on Stacks applications — navigation, screenshots, responsive testing, console/network monitoring, and accessibility snapshots. Dependency-free: drives a system browser over the Chrome DevTools Protocol using only Bun (no Playwright/Puppeteer). Invoke with /stacks-browse.