Scaffold

From fortunto2/solo-factory · View interactive version

Scaffold is an AI agent skill from the GitHub repository fortunto2/solo-factory. Use when "scaffold project", "create new project", "start new app", "bootstrap project", "set up from PRD", or need project from PRD + stack template. Do NOT use for planning features (/plan) or PRD generation (/validate).

How to use this skill

Skill file

/scaffold

Scaffold a complete project from PRD + stack template. Creates directory structure, configs, CLAUDE.md, git repo, and pushes to GitHub. Studies existing projects via SoloGraph for consistent patterns, uses Context7 for latest library versions.

Steps

  1. Parse arguments from $ARGUMENTS — extract <project-name> and <stack-name>.

If MCP project_info available, also show detected stacks from active projects.

List stack names with one-line descriptions from each YAML's description field.

  1. Load org defaults from ~/.solo-factory/defaults.yaml:
  1. Load stack + PRD + principles:
  1. Study existing projects via SoloGraph (learn from your own codebase — critically):

Before generating code, study active projects with the same stack. Don't blindly copy — existing projects may have legacy patterns or mistakes. Evaluate what's actually useful.

a. Find sibling projects — use project_info() to list active projects, filter by matching stack.

Example: for ios-swift, find existing projects with matching stack.

b. Architecture overview — project_info(name="<sibling>") for each sibling.

Gives: directory layers, key patterns (base classes, protocols, CRUD), top dependencies, files with the most definitions.

c. Search for reusable patterns in the sibling — Grep/Glob under its path (from project_info), or symbol names across projects with symbol_search("<words>"):

d. Check shared packages — the dependencies in project_info(name="<sibling>"), and project_info() for what several projects already use.

Collect package versions for reference (but verify with Context7 for latest).

e. Critically evaluate what to adopt vs skip:

Goal: Generated code should feel consistent with your portfolio but use the best available patterns, not just the same old ones.

Limit to 2-3 sibling projects to keep research focused.

  1. Context7 research (latest library versions and best practices):
  1. Show plan + get confirmation via AskUserQuestion:
  1. Create project directory:

```bash

mkdir -p <projects_dir>/<name>

```

  1. Create file structure based on the stack. SGR-first: always start with domain schemas/models before any logic or views. Every project gets these common files:

```

<projects_dir>/<name>/

├── CLAUDE.md # AI-friendly project docs (map, not manual — see Harness Engineering)

├── Makefile # Common commands (run, test, build, lint, deploy, integration)

├── README.md # Human-friendly project docs

├── docs/

│ ├── prd.md # Copy of PRD

│ ├── QUALITY_SCORE.md # Domain quality grades (harness: garbage collection)

│ └── ARCHITECTURE.md # Module boundaries and dependency rules

├── cli/ # CLI utility — mirrors core business logic (CLI-First Testing principle)

│ └── main.ts|py # Deterministic pipeline entry point (no LLM required)

├── .claude/

│ └── skills/ # Product-specific workflow skills

│ └── dev/

│ └── SKILL.md # Dev workflow skill (run, test, deploy)

└── .gitignore # Stack-specific ignores

```

CLI-First Testing: generate a cli/ directory with a stub that imports core business logic from lib/ (or equivalent). The CLI should run the main pipeline deterministically without requiring LLM, network, or UI. This enables make integration for pipeline verification. See dev-principles.md → "CLI-First Testing".

### .claude/skills/dev/SKILL.md — product dev workflow skill

Generate a skill that teaches Claude how to work with THIS specific project. Structure:

```yaml


name: <name>-dev

description: Dev workflow for <Name> — run, test, build, deploy. Use when working on <Name> features, fixing bugs, or deploying changes. Do NOT use for other projects.

license: MIT

metadata:

author: <github_org>

version: "1.0.0"

allowed-tools: Read, Grep, Glob, Bash, Write, Edit


```

Body should include:

This makes every scaffolded project immediately Claude-friendly — new sessions get project context via the skill.

MCP server (optional): If PRD indicates a data/AI/developer product, also generate MCP server stub.

See templates/mcp-skills-bundle.md for the full "MCP + Skills bundle" pattern and rules for when to generate MCP.

Then add stack-specific files. See references/stack-structures.md for per-stack file listings (8 stacks: nextjs, ios, kotlin, cloudflare, astro-static, astro-hybrid, python-api, python-ml).

  1. Generate Makefile — stack-adapted with: help, dev, test, lint, format, build, clean, deploy targets.
  1. Generate CLAUDE.md for the new project (~100 lines, map not manual):

1. "Am I building bullshit?" — re-read the request

2. "Is this code garbage?" — would a senior accept this?

3. "How to make this amazing?" — what insight is everyone missing?

Lists available MCP tools: kb_search, session_search, symbol_search, project_info

  1. Generate README.md — project name, description, prerequisites, setup, run/test/deploy.
  1. Generate .gitignore — stack-specific patterns.
  1. Copy PRD to docs/: Copy from knowledge base or generate in place.
  1. Git init + first commit:

```bash

cd <projects_dir>/<name>

git init && git add . && git commit -m "Initial project scaffold

Stack: <stack-name>

Generated by /scaffold"

```

  1. Create GitHub private repo + push:

```bash

cd <projects_dir>/<name>

gh repo create <name> --private --source=. --push

```

  1. Register project + add it to the code graph (optional, if solograph is installed):

```

solograph registry && solograph scan -p <name>

```

The nightly refresh keeps it current after that.

  1. Output summary:

```

Project scaffolded!

Path: <projects_dir>/<name>

GitHub: https://github.com/<user>/<name>

Stack: <stack-name>

PRD: docs/prd.md

CLAUDE: configured

Skills: .claude/skills/dev/ (project workflow)

Next steps:

cd <projects_dir>/<name>

<install command> # pnpm install / uv sync / etc.

<run command> # pnpm dev / uv run ... / etc.

Then: /setup → /plan "First feature" → /build

```

Verification

Before reporting "project scaffolded":

  1. Verify all generated files exist (ls the directory tree).
  2. Run the install command (pnpm install, uv sync, etc.) — must succeed.
  3. Run the dev/build command if applicable — must not error.
  4. Verify git init + first commit succeeded (git log --oneline -1).
  5. Verify GitHub repo creation (gh repo view or check URL).

Never say "scaffold complete" without running the install and verifying it works.

Common Issues

Stack YAML not found

Cause: Stack template missing from templates/stacks/ or not symlinked.

Fix: Skill uses built-in knowledge if template not found. To fix: ensure solo-factory/templates/stacks/<stack>.yaml exists.

GitHub repo creation fails

Cause: gh CLI not authenticated or repo name already taken.

Fix: Run gh auth login first. If name taken, choose a different project name.

Context7 queries fail

Cause: MCP server not running or Context7 rate limited.

Fix: Skill proceeds with stack YAML versions as fallback. Context7 enhances but is not required.

org defaults missing

Cause: ~/.solo-factory/defaults.yaml not created.

Fix: Run /init first for one-time setup, or skill will ask for bundle ID and team ID interactively.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.