Expert guidance for working with the amp-templates monorepo - an Effect-TS powered CLI tool for scaffolding Amp applications with Next.js, Vite, and backend templates
Expert guidance for developing and extending the amp-templates monorepo - a TypeScript CLI tool built with Effect-TS for scaffolding Amp-powered applications.
Provides comprehensive development support for the amp-templates repository, including:
**Monorepo Layout:**
**Template Categories:**
The CLI is built entirely with Effect-TS functional programming:
**Key Modules:**
**Effect Patterns Used:**
Templates are NOT bundled with the CLI:
1. Downloads `https://codeload.github.com/edgeandnode/amp-templates/tar.gz/main`
2. Extracts specific template directory path
3. Strips parent directories and writes to target project
4. Post-processes `package.json` to set project name
5. Optionally runs `git init` and package manager install
**Check prerequisites:**
**Install dependencies:**
```bash
pnpm install
```
**Build all packages:**
```bash
pnpm build
```
**Run CLI in development mode:**
```bash
cd packages/create-amp
pnpm create-amp my-app
```
**CLI options:**
```bash
pnpm create-amp my-app --template backend-express --package-manager pnpm
pnpm create-amp my-app --skip-install-deps --skip-initialize-git
```
**Available templates:**
**Create template directory:**
```bash
mkdir -p templates/backend/my-new-template
```
**Add template files:**
**Register template in `packages/create-amp/src/internal/Templates.ts`:**
```typescript
export const AVAILABLE_TEMPLATES = {
// ... existing templates
"my-new-template": {
key: "my-new-template",
name: "My New Template",
description: "Description shown in CLI prompts",
directory: "/templates/backend/my-new-template",
skip: new Set([...Constants.ALWAYS_SKIP_DIRECTORIES, "dist", ".next"]),
type: "build-dataset" // or "existing-dataset"
}
} as const
```
**Update type definition in `packages/create-amp/src/Domain.ts`:**
```typescript
export type AvailableTemplateFrameworkKey =
| "backend-express"
// ... existing keys
| "my-new-template"
```
**Template types:**
**Use Effect.gen for imperative-style composition:**
```typescript
const myFunction = Effect.fn("MyFunction")(function* (config: Config) {
const fs = yield* FileSystem.FileSystem
const path = yield* Path.Path
yield* fs.makeDirectory(config.appName, { recursive: true })
yield* GitHub.GitHubService.downloadTemplate(config.appName, template)
return Result.success
})
```
**Define custom errors:**
```typescript
export class MyCustomError extends Data.TaggedError("MyCustomError")<{
readonly message: string
readonly cause?: unknown
}> {}
```
**Create Effect Services:**
```typescript
export class MyService extends Effect.Service<MyService>()("MyService", {
effect: Effect.gen(function* () {
// service implementation
return {
myMethod: (arg: string) => Effect.succeed(result)
}
})
}) {}
```
**Use Effect Schema for validation:**
```typescript
export const MySchema = Schema.Struct({
name: Schema.String,
count: Schema.Number
})
export type MyType = Schema.Schema.Type<typeof MySchema>
```
**Run tests:**
```bash
pnpm test
```
**Run tests with coverage:**
```bash
pnpm test:coverage
```
**Lint code:**
```bash
pnpm lint
```
**Auto-fix lint issues:**
```bash
pnpm lint:fix
```
**Format code:**
```bash
pnpm format
```
**Build all packages:**
```bash
pnpm build
```
**TypeScript Configuration:**
**Code Style (enforced by Prettier + ESLint):**
**Testing Framework:**
**Add a new CLI option:**
1. Add option definition in `packages/create-amp/src/Cli.ts` using `@effect/cli` primitives
2. Add to command options tuple
3. Update handler logic to use the new option
**Modify template skip patterns:**
Edit the `skip` set in `AVAILABLE_TEMPLATES`:
```typescript
skip: new Set([
...Constants.ALWAYS_SKIP_DIRECTORIES, // .git, node_modules
"dist",
".next",
".tanstack",
"coverage"
])
```
**Update package manager support:**
Modify package manager resolution in `src/Cli.ts` (currently supports: pnpm, npm, yarn, bun)
**Work with workspace dependencies:**
Use workspace protocol in `package.json`:
```json
{
"dependencies": {
"@amp-templates/create-amp": "workspace:*"
}
}
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/amp-templates-cli-development-assistant/raw