CLI Reference

contxt pattern

Capture recurring code patterns and conventions. Patterns teach AI how your codebase is structured — so it generates code that fits rather than code you have to rewrite.

Add a pattern

contxt pattern add

Fields

FieldDescription
titleName of the pattern (e.g. "API route error handling")
descriptionWhen and why to use this pattern
exampleA code snippet showing the pattern in practice

Patterns vs Decisions

Use a Pattern when...
  • You have a repeatable code structure
  • You want AI to follow a naming convention
  • It's about how to write code
Use a Decision when...
  • You chose one option over another
  • There's a rationale worth preserving
  • It's about why you chose something

Example

Sample pattern
Title: Next.js API route structure
Description: All API routes validate auth first, then parse the request body, then perform the operation. Errors are returned as JSON with a consistent shape.
Example:
export async function POST(req) {
  const { user } = await requireAuth(req);
  const body = await req.json();
  // ... operation
  return NextResponse.json({ data });
}