Skip to content

create-scratchy-app

Diátaxis type: Reference + How-to Guide — installation commands, CLI options, feature selection, and generated project structure.

Table of Contents


Overview

create-scratchy-app is the official project scaffolding CLI for the Scratchy framework. It creates a fully configured, production-ready starter application with Fastify, tRPC, Drizzle ORM, Better Auth, Qwik, and Tailwind CSS — all wired up and ready to run.

The CLI is interactive by default, guiding you through project setup with sensible defaults. It can also be run non-interactively with the --yes flag for CI/automation workflows.

Quick Start

bash
# With pnpm (recommended)
pnpm create scratchy-app my-app

# With npm
npx create-scratchy-app my-app

# With yarn
yarn create scratchy-app my-app

# With bun
bun create scratchy-app my-app

After scaffolding completes, follow the printed next-steps to configure your environment and start the dev server.

Installation

create-scratchy-app is designed to be run via your package manager's create command — no global install is required.

bash
# Recommended — runs the latest version without installing globally
pnpm create scratchy-app
npx create-scratchy-app

The package is published as @scratchyjs/create-scratchy-app with two bin entries:

BinaryUsage
create-scratchypnpm create scratchy my-app
create-scratchy-apppnpm create scratchy-app my-app or npx create-scratchy-app my-app

Both binaries are identical — use whichever you prefer.

CLI Options

create-scratchy-app [project-name] [options]
OptionShortDescriptionDefault
[project-name]Name and directory for the new projectPrompted
--yes-ySkip all prompts and use default valuesfalse
--version-vPrint the CLI version and exit
--help-hShow usage information and exit

Examples

bash
# Fully interactive — prompts for everything
pnpm create scratchy-app

# Provide project name, prompted for features
pnpm create scratchy-app my-app

# Skip all prompts — use all defaults
pnpm create scratchy-app my-app --yes

# Check version
npx create-scratchy-app --version

# Show help
npx create-scratchy-app --help

Interactive Mode

When run without --yes, the CLI walks you through these prompts:

PromptTypeDefaultNotes
Project nameTextmy-scratchy-appMust match ^[a-z0-9][-a-z0-9._]*$
Include Drizzle ORM?ConfirmYesPostgreSQL + DragonflyDB
Include Better Auth?ConfirmYesAuto-enables DB if selected
Include Piscina SSR?ConfirmYesWorker thread rendering pool
Initialise git?ConfirmYesRuns git init + initial commit
Package managerSelectAuto-detectedpnpm, npm, yarn, or bun
Install dependencies?ConfirmYesRuns install with selected package manager

If the target directory already exists and is not empty, you will be asked whether to continue and potentially overwrite files.

Auth requires Database

If you select Better Auth but deselect Database, the CLI automatically enables the database — auth needs Drizzle ORM for session and account storage.

Feature Selection

The CLI allows you to opt out of individual framework features. When you deselect a feature, the corresponding files, imports, server configuration blocks, and environment variables are cleanly removed from the generated project.

Database (Drizzle ORM + PostgreSQL)

Included by default. When deselected:

  • src/db/ directory is removed
  • src/auth.ts is removed (auth depends on DB)
  • drizzle.config.ts is removed
  • docker-compose.yml is removed
  • DATABASE_URL, DATABASE_SCHEMA, and REDIS_URL are stripped from .env.example
  • Database and auth blocks are removed from src/server.ts

Authentication (Better Auth)

Included by default. When deselected:

  • src/auth.ts is removed
  • src/db/schema/auth-tables.ts is removed
  • Auth table exports are removed from src/db/schema/index.ts
  • BETTER_AUTH_SECRET and ORIGIN are stripped from .env.example
  • Auth blocks are removed from src/server.ts

Renderer (Piscina SSR)

Included by default. When deselected:

  • src/renderer/ directory is removed
  • Renderer blocks (worker pool setup + SSR catch-all route) are removed from src/server.ts

Generated Project Structure

With all features enabled, the scaffolded project looks like this:

my-app/
├── .env.example              # Environment variable template
├── .github/
│   └── instructions/         # AI coding assistant guidance
│       ├── scratchy.instructions.md
│       └── security.instructions.md
├── .gitignore
├── AGENTS.md                 # AI agent guidance (Copilot, Claude, etc.)
├── README.md
├── docker-compose.yml        # PostgreSQL + DragonflyDB
├── drizzle.config.ts         # Drizzle Kit configuration
├── package.json
├── tsconfig.json
├── vite.config.ts            # Vite + Qwik + Tailwind
├── public/                   # Static assets
└── src/
    ├── index.ts              # Application entry point
    ├── server.ts             # Fastify server setup + plugin registration
    ├── config.ts             # Zod environment schema
    ├── router.ts             # tRPC initialisation + middleware
    ├── context.ts            # tRPC context factory
    ├── auth.ts               # Better Auth instance
    ├── db/                   # Database layer (Drizzle ORM)
    │   ├── index.ts          # Drizzle instance + connection pool
    │   ├── my-schema.ts      # PostgreSQL schema namespace
    │   └── schema/           # Table definitions (one file per entity)
    │       ├── index.ts      # Barrel export
    │       ├── columns.helpers.ts
    │       ├── user.ts
    │       ├── post.ts
    │       └── auth-tables.ts
    ├── routers/              # tRPC routers (internal API)
    │   ├── index.ts          # Router aggregation
    │   └── posts/
    │       ├── queries.ts    # Post query procedures
    │       └── mutations.ts  # Post mutation procedures
    ├── renderer/             # Piscina worker thread (SSR)
    │   └── worker.ts
    ├── types/                # TypeScript augmentations
    │   └── fastify.d.ts
    └── client/               # Client-side code (bundled by Vite)
        ├── routes/
        │   ├── layout.tsx    # Root Qwik layout
        │   └── index.tsx     # Home page
        └── styles/
            └── global.css    # Tailwind CSS entry point

Template Stack

LayerPackageRole
HTTP server@scratchyjs/coreFastify with CORS, helmet, rate-limiting
Authentication@scratchyjs/authBetter Auth with email/password
Database@scratchyjs/drizzleDrizzle ORM with PostgreSQL
API@scratchyjs/trpcType-safe tRPC router
Rendering@scratchyjs/rendererPiscina SSR worker pool
Client bundling@scratchyjs/vite-pluginVite + Qwik + Tailwind CSS
Utilities@scratchyjs/utilsRequest helpers (IP, locale, prefetch, …)

Environment Variables

The generated .env.example includes all variables needed to run the application:

VariableDefaultFeatureDescription
PORT3000CoreServer port
HOST0.0.0.0CoreServer host
NODE_ENVdevelopmentCoreEnvironment mode
LOG_LEVELinfoCorePino log level
TRUST_PROXYtrueCoreTrust X-Forwarded-* headers
DATABASE_URLpostgresql://scratchy:scratchy@localhost:5432/scratchyDatabasePostgreSQL connection string
DATABASE_SCHEMAappDatabaseCustom PostgreSQL schema namespace
REDIS_URLredis://localhost:6379DatabaseDragonflyDB (Redis-compatible) URL
BETTER_AUTH_SECRETAuthSecret key for session signing (min 32 chars)
ORIGINhttp://localhost:3000AuthApplication base URL for trusted-origin validation

Scripts

ScriptCommandDescription
devtsx src/index.tsStart the development server
typechecktsc --noEmitType-check with TypeScript
db:generatedrizzle-kit generateGenerate Drizzle migration files
db:migratedrizzle-kit migrateApply pending migrations
db:studiodrizzle-kit studioOpen Drizzle Studio

Non-Interactive Mode

Use --yes (or -y) to skip all prompts and scaffold with defaults:

bash
pnpm create scratchy-app my-app --yes

Default values in non-interactive mode:

SettingDefault Value
Project namemy-scratchy-app
DatabaseIncluded
AuthenticationIncluded
RendererIncluded
Git initYes
Package managerAuto-detected
Install depsYes

This is useful for CI pipelines, automation scripts, or when you want the full stack without any questions.

Package Manager Detection

The CLI auto-detects which package manager you are using by inspecting the npm_config_user_agent environment variable that package managers set when running create commands:

User agent prefixDetected as
pnpm/*pnpm
yarn/*yarn
bun/*bun
Other / unsetnpm

The detected package manager is used as the default selection in the interactive prompt and determines the correct install/run commands shown in next-steps.