This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Spot is a TypeScript-based API contract definition tool that generates OpenAPI, Swagger, and JSON Schema documentation from TypeScript decorator syntax. It allows developers to write API contracts using familiar TypeScript syntax instead of YAML/JSON.
pnpm build- Compile TypeScript to JavaScript output inbuild/directorypnpm build:watch- Compile with watch mode for development
pnpm test- Run all tests with Jest (uses 4 workers)pnpm ci:test- Run tests in CI mode with coverage reporting- Single test:
pnpm test path/to/test.spec.tsorpnpm test -- --testNamePattern="test name"
pnpm lint:check- Run both ESLint and Prettier checkspnpm lint:fix- Auto-fix ESLint and Prettier issuespnpm eslint:check/pnpm eslint:fix- Run ESLint onlypnpm prettier:check/pnpm prettier:fix- Run Prettier only
npx @airtasker/spot generate --contract api.ts --generator openapi3 --out output/- Generate OpenAPI3 from contractnpx @airtasker/spot lint api.ts- Lint a Spot contractnpx @airtasker/spot mock api.ts- Run mock server from contractnpx @airtasker/spot validate api.ts- Validate contract syntax
lib/src/- Main library codecore.ts- Main API exposing parsers and generatorslib.ts- Library entry pointsyntax/- TypeScript decorator definitions for API contracts (@api, @endpoint, @request, @response, etc.)generators/- Code generators for different output formatsparser/- TypeScript AST parsing logiclinting/- Contract validation and linting rules
generators/openapi2/- OpenAPI 2.0 (Swagger) generatorgenerators/openapi3/- OpenAPI 3.x generatorgenerators/json-schema/- JSON Schema generator
cli/src/commands/- OCLIF-based CLI commands- Each command corresponds to a spot CLI function (generate, lint, mock, etc.)
- Contracts - TypeScript files with @api decorated classes defining API structure
- Endpoints - @endpoint decorated classes defining individual API endpoints
- Decorators - @request, @response, @body, @pathParams, @queryParams, @headers for API components
- Generators - Transform parsed contracts into target formats (OpenAPI, JSON Schema)
- Linting Rules - Validate contract structure and enforce best practices
- Strict TypeScript settings enabled
- Experimental decorators enabled for syntax support
- Builds to CommonJS modules targeting ES2019
- Path mapping:
@airtasker/spot→./lib/src/lib
- Jest with ts-jest preset
- Tests located alongside source files with
.spec.tsextension - Spec examples in
__spec-examples__/directories for testing generators - Test coverage configured for CI
- The project uses a monolithic structure with both library and CLI in the same repository
- TypeScript decorators are central to the API - any changes to syntax should consider backward compatibility
- Generator output is tested against snapshot files to catch breaking changes
- The linting system is extensible - new rules can be added in
lib/src/linting/rules/ - OCLIF handles CLI structure - new commands should follow existing patterns in
cli/src/commands/