Skip to content

Installation

Before you begin, make sure you have the following:

The fastest way to start a new Stratal project is with create-stratal:

Terminal window
npm create stratal@latest my-app

The CLI will prompt you to pick a template and package manager, then scaffold the project and install all dependencies.

To skip the interactive picker, pass the --template flag directly:

Terminal window
npm create stratal@latest my-app --template hello-world

The generated project (hello-world template) looks like this:

my-app/
├── src/
│ ├── app.module.ts
│ ├── hello.controller.ts
│ └── index.ts
├── package.json
├── tsconfig.json
└── wrangler.jsonc

Start the dev server:

Terminal window
cd my-app
npm run dev

Head to Your First Worker for a walkthrough of the generated code.

Stratal provides AI skills that teach your AI agent the framework’s conventions, patterns, and APIs. With the skill installed, your AI agent can scaffold new projects, generate controllers, services, and modules, and wire dependency injection — all following Stratal best practices.

Terminal window
npx skills add strataljs/stratal

This installs the Stratal skill into your project’s .agents/ directory. Your AI agent automatically discovers and uses the skill when working with Stratal code.

Stratal can also expose your API routes as Model Context Protocol (MCP) tools, letting AI agents discover and call your endpoints directly. Since Stratal generates an OpenAPI spec from your routes out of the box, the MCP server works with no additional setup.

Preview which routes are available as tools:

Terminal window
npx quarry mcp:tools

Start the MCP server:

Terminal window
npx quarry mcp:serve

See AI Integration for client configuration, filtering options, and remote dispatch.

If you already have a project and want to add Stratal to it, follow the steps below.

Install Stratal:

Terminal window
npm install stratal reflect-metadata

Then install the dev dependencies:

Terminal window
npm install -D typescript wrangler @cloudflare/workers-types

Create a tsconfig.json in the project root. Stratal uses TypeScript decorators, so both experimentalDecorators and emitDecoratorMetadata must be enabled:

{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "bundler",
"strict": true,
"skipLibCheck": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"isolatedModules": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"outDir": "./dist",
"rootDir": "./src",
"types": ["@cloudflare/workers-types/2023-07-01"]
},
"include": ["src/**/*"]
}

Create a wrangler.jsonc file to configure how Cloudflare deploys your worker:

{
"name": "my-worker",
"main": "src/index.ts",
"compatibility_date": "2026-02-25",
"compatibility_flags": ["nodejs_compat"],
"vars": {
"ENVIRONMENT": "development"
},
"kv_namespaces": [
{ "binding": "CACHE", "id": "<your-kv-namespace-id>" }
]
}

Key settings:

  • main — points to your worker entry file.
  • nodejs_compat — required so Stratal can use Node.js APIs.
  • ENVIRONMENT — a variable Stratal reads at runtime.
  • CACHE — a KV namespace binding used by Stratal’s built-in caching layer. You can create one with npx wrangler kv namespace create CACHE and paste the returned id into the config.

Add a dev script to your package.json:

{
"scripts": {
"dev": "wrangler dev"
}
}

Create the source directory:

Terminal window
mkdir src

Your project should now look like this:

my-worker/
├── src/
├── package.json
├── tsconfig.json
└── wrangler.jsonc

Everything is in place. Head to Your First Worker to create the entry point and build your first route.