Context
- Current directory: !
pwd
- Project CLAUDE.md: !
head -80 CLAUDE.md 2>/dev/null || echo "no CLAUDE.md"
- Package.json: !
cat package.json 2>/dev/null | head -40 || echo "no package.json"
- Project structure: !
find . -maxdepth 3 -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.astro" -o -name "*.vue" -o -name "*.py" -o -name "*.sh" \) 2>/dev/null | grep -v node_modules | grep -v .git | grep -v dist | sort | head -40
Mode detection
Parse $ARGUMENTS for type and name:
page about → type: page, name: about
component UserCard → type: component, name: UserCard
api users → type: api, name: users
- Empty → use AskUserQuestion
Supported types
| Type |
Description |
Typical location |
page |
Route/page file |
src/pages/, app/, pages/ |
component |
UI component |
src/components/, components/ |
layout |
Layout wrapper |
src/layouts/, app/layout |
api |
API route/endpoint |
src/pages/api/, app/api/, convex/ |
content |
Content/blog post |
src/content/, content/ |
hook |
Custom hook |
src/hooks/, hooks/ |
util |
Utility function |
src/utils/, src/lib/, utils/ |
Flow
Step 1: Parse arguments
If $ARGUMENTS is empty, use AskUserQuestion:
- Q1: "What type of file should I scaffold?"
- Options: page, component, layout, api, content, hook, util
- Q2: "What name?" (free text — user types via "Other")
Step 2: Find existing examples
Find 2-3 existing files of the same type in the project:
# For pages:
find src/pages -maxdepth 2 -type f | head -3
# For components:
find src/components -maxdepth 2 -type f | head -3
# etc.
Read each example file completely.
Step 3: Analyze patterns
From the examples, extract:
- File extension:
.astro, .tsx, .vue, .py, etc.
- Naming convention: PascalCase, kebab-case, camelCase
- Import style: relative vs alias (
@/), named vs default
- Component structure: function vs arrow, export style
- Styling approach: Tailwind classes, CSS modules, scoped styles
- TypeScript patterns: interface vs type, Props naming, generics
- Frontmatter: Astro frontmatter patterns, metadata
- Framework patterns:
getStaticPaths, loader, useQuery, etc.
Step 4: Generate new file
Create the new file matching EXACTLY the patterns found:
- Same file extension
- Same naming convention
- Same import style and structure
- Same export pattern
- Same styling approach
- Placeholder content that matches the pattern
Step 5: Report
SCAFFOLDED: [type] — [name]
─────────────────────────────
File: [created file path]
Based on: [example files used]
Patterns: [key patterns matched]
─────────────────────────────
Important
- Never invent patterns. Always derive from existing files in the project.
- Consistency > creativity. The generated file should look like it was written by the same developer.
- If no examples of the requested type exist, tell the user and ask how to proceed.
- For Astro projects: detect whether to use
.astro, .tsx, or .vue based on existing patterns.
- For content files: use the project's content schema (Content Collections, MDX frontmatter).
- Name the file following the project's existing naming convention (don't impose a different one).
- Place the file in the correct directory based on where existing files of that type live.
1---2name: shipflow-scaffold3description: Generate new files matching existing project patterns — pages, components, layouts, API routes, hooks, utils4---5
6## Context
7
8- Current directory: !`pwd`
9- Project CLAUDE.md: !`head -80 CLAUDE.md 2>/dev/null || echo "no CLAUDE.md"`
10- Package.json: !`cat package.json 2>/dev/null | head -40 || echo "no package.json"`
11- Project structure: !`find . -maxdepth 3 -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.astro" -o -name "*.vue" -o -name "*.py" -o -name "*.sh" \) 2>/dev/null | grep -v node_modules | grep -v .git | grep -v dist | sort | head -40`
12
13## Mode detection
14
15Parse `$ARGUMENTS` for type and name:
16- `page about` → type: page, name: about
17- `component UserCard` → type: component, name: UserCard
18- `api users` → type: api, name: users
19- Empty → use AskUserQuestion
20
21---
22
23## Supported types
24
25| Type | Description | Typical location |
26|------|-------------|-----------------|
27| `page` | Route/page file | `src/pages/`, `app/`, `pages/` |
28| `component` | UI component | `src/components/`, `components/` |
29| `layout` | Layout wrapper | `src/layouts/`, `app/layout` |
30| `api` | API route/endpoint | `src/pages/api/`, `app/api/`, `convex/` |
31| `content` | Content/blog post | `src/content/`, `content/` |
32| `hook` | Custom hook | `src/hooks/`, `hooks/` |
33| `util` | Utility function | `src/utils/`, `src/lib/`, `utils/` |
34
35## Flow
36
37### Step 1: Parse arguments
38
39If `$ARGUMENTS` is empty, use **AskUserQuestion**:
40- Q1: "What type of file should I scaffold?"
41 - Options: page, component, layout, api, content, hook, util
42- Q2: "What name?" (free text — user types via "Other")
43
44### Step 2: Find existing examples
45
46Find 2-3 existing files of the same type in the project:
47
48```bash
49# For pages:
50find src/pages -maxdepth 2 -type f | head -3
51# For components:
52find src/components -maxdepth 2 -type f | head -3
53# etc.
54```
55
56Read each example file completely.
57
58### Step 3: Analyze patterns
59
60From the examples, extract:
61- **File extension**: `.astro`, `.tsx`, `.vue`, `.py`, etc.
62- **Naming convention**: PascalCase, kebab-case, camelCase
63- **Import style**: relative vs alias (`@/`), named vs default
64- **Component structure**: function vs arrow, export style
65- **Styling approach**: Tailwind classes, CSS modules, scoped styles
66- **TypeScript patterns**: interface vs type, Props naming, generics
67- **Frontmatter**: Astro frontmatter patterns, metadata
68- **Framework patterns**: `getStaticPaths`, `loader`, `useQuery`, etc.
69
70### Step 4: Generate new file
71
72Create the new file matching EXACTLY the patterns found:
73- Same file extension
74- Same naming convention
75- Same import style and structure
76- Same export pattern
77- Same styling approach
78- Placeholder content that matches the pattern
79
80### Step 5: Report
81
82```
83SCAFFOLDED: [type] — [name]
84─────────────────────────────
85File: [created file path]
86Based on: [example files used]
87Patterns: [key patterns matched]
88─────────────────────────────
89```
90
91---
92
93## Important
94
95- **Never invent patterns.** Always derive from existing files in the project.
96- **Consistency > creativity.** The generated file should look like it was written by the same developer.
97- If no examples of the requested type exist, tell the user and ask how to proceed.
98- For Astro projects: detect whether to use `.astro`, `.tsx`, or `.vue` based on existing patterns.
99- For content files: use the project's content schema (Content Collections, MDX frontmatter).
100- Name the file following the project's existing naming convention (don't impose a different one).
101- Place the file in the correct directory based on where existing files of that type live.