v0.1 · free · open source

Four AI config files.
One command. Thirty seconds.

Every AI tool wants its own config — Cursor, Claude Code, Copilot, Windsurf. contextarch detects your stack and generates all four, consistent with each other, tuned to what you actually use.

$ npx contextarch init
# detects stack → asks 6 questions → writes 4 files

What lands on disk

Four files, every run. Same core behavior rules so every agent in your editor acts the same.

.cursorrules
Cursor
AGENTS.md
Windsurf · emerging standard
CLAUDE.md
Claude Code
.github/
copilot-instructions.md
GitHub Copilot

Why this exists

Four tools, four config formats, zero consistency. Most rules are copied from a blog post and never updated.

Detects your stack — reads `package.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`, `tsconfig.json`, `Dockerfile`, lockfiles. Picks React vs Next.js, FastAPI vs Django, and so on.
Writes all four files from one source. Cursor, Claude Code, Copilot, Windsurf — same rules, same behavior, four formats.
Opinionated, not generic. Specific anti-patterns and preferences that actually change AI output. Not "write clean code" slop.

How it works

No install, no account, no config file to learn. 60-second wizard, four files on disk.

01

Run the command in any repo

`npx contextarch init` fetches the CLI on demand — nothing to install. Works on Node.js 18+.

02

Stack detected, 6 questions asked

Project kind, coding style (strict / pragmatic / fast-iteration), verbosity, testing emphasis, any project-specific rules. Smart defaults from your manifests — usually you just hit enter.

03

Four files land

Existing files get `.bak` backups by default. Re-run any time with `--overwrite` to regenerate.

What the output looks like

Real excerpts for four stacks. Same core rules, stack-specific guidance — no generic filler.

.cursorrules
### Next.js (App Router)
- Server Components by default. Add "use client" only when you need
  state, effects, or browser APIs.
- Data fetching lives in Server Components or Route Handlers — not in useEffect.
- Server Actions for mutations — always validate inputs with Zod/Valibot
  before doing work.
- Cache with fetch options (next: { revalidate }, cache: 'force-cache') — don't reinvent.

### Prisma
- Schema is the source of truth. Migrations via prisma migrate, never raw SQL drift.
- Select only needed fields (select: { ... }) — don't return full rows to clients.
- Wrap multi-step mutations in prisma.$transaction([...]).
- Singleton client in server code; don't instantiate new PrismaClient() per request.
.cursorrules
### FastAPI
- Pydantic v2 models for every request body and response. Let FastAPI do the validation.
- Dependency injection via Depends(...) — don't import globals inside routes.
- Async routes for I/O-bound work; sync when the library is sync (don't fake async).
- Return typed response models via response_model= — don't leak ORM objects.

### Python
- Type hints on every function signature. Use mypy --strict or pyright in CI.
- f-strings for formatting. Never % or .format() in new code.
- Prefer pathlib.Path over os.path. Use match/case where it clarifies branching.
.cursorrules
### Go
- Go 1.22+ features are fair game. Prefer the standard library.
- Errors as values — wrap with fmt.Errorf("context: %w", err) and
  check with errors.Is/As.
- Return early. Avoid nested if err == nil pyramids.
- Accept interfaces, return structs. Keep interfaces small — define them where consumed.
- Context propagation: every I/O function takes ctx context.Context as the first arg.
- Table-driven tests with t.Run(name, ...) subtests.

Avoid:
- Panicking in library code for recoverable errors.
- Stuffing everything in package main.
.cursorrules
### SvelteKit
- Load data in +page.server.ts / +page.ts — never fetch in the component
  <script> block.
- Form actions for mutations. Use progressive enhancement (use:enhance).
- Stores (writable, readable) for shared state; prefer $state runes in Svelte 5.
- Put server-only code in $lib/server/ so it can't leak to the client bundle.

### TypeScript
- Never use any — use unknown and narrow, or write a proper type.
- Import types with import type { ... } to avoid runtime import cost.
- Prefer discriminated unions over enums.

Supported stacks

Thirty-plus stack tags out of the box. Detection reads your actual manifests, so you usually don't pick anything.

React · Next.js · Vue · SvelteKit · Astro · Remix · Node · Electron · Express · Fastify · NestJS · Hono · Tailwind · Prisma · Drizzle · Supabase · Vitest · Jest · FastAPI · Django · Flask · Pytest · Go · Rust · Rails · Laravel · Postgres · MongoDB · Redis · Docker — missing one? Open an issue.
$ npx contextarch init
Star on GitHub ↗