Skip to content

Getting Started

listenrightmeow edited this page Jul 18, 2026 · 2 revisions

Getting Started

Install

npm install --save-dev @mmmnt/feature
npx feat init   # scaffolds config + first spec, installs the runtime, adapters, and vitest
  • @mmmnt/feature provides the feat CLI.
  • @mmmnt/feat-runtime is the library your generated tests import.
  • Adapters connect specs to your code and infrastructure — install the ones your feat.config.json names. (vitest is the test runner; install it if you don't have it.)

Initialize

npx feat init

This creates three files:

feat.config.json            # how specs connect to your project
specs/greet.feat            # a first spec
specs/greet.contract.json   # its schemas (plain JSON Schema)

The loop

npx feat parse specs/greet.feat    # 1. validate the spec
npx feat generate                  # 2. compile specs → test files
npx feat run                       # 3. execute them (red until you implement)

The scaffolded spec routes the Greet command to src/greet.ts — a plain async function that returns { status, body }:

// src/greet.ts
export async function greet(input: { name: string }) {
  if (!input.name.trim())
    return { status: "ERR", body: { code: "EMPTY_NAME", message: "Name is required." } };
  return { status: "OK", body: { message: `Hello, ${input.name}!` } };
}

Implement it, run npx feat run again, and the generated suite goes green. That's the whole workflow: spec → generate → implement → run, with feat verify keeping the generated tests locked to the specs in CI.

Wire it into CI

npx feat verify           # committed tests match the specs (byte-for-byte)
npx feat run --coverage   # predictions hold; coverage via the runner's provider
npx feat report --junit   # JUnit XML path for your CI's test ingestion

Next

Clone this wiki locally