Add the AI setup to a project you already have

One command adds an .ai/ folder to your repository. Your own lint, test and build commands become one verification loop, AI agents get rules and a specification to work from, and “done” means nothing that passed yesterday fails today. Your code, your dependencies and your CI are not touched.

No account or login Needs Node 20+ and a terminal Reads your folder and writes into it; sends nothing anywhere

This page cannot read your folder (a browser may not), so the command line does the work. Everything it does is explained below and in the full guide.

Your command

Answer four questions; copy the command; run it in a terminal.

Quoted for you if it has spaces. Leave empty for the folder you are in.

Can be changed later with ./.ai/sdlc agent. Agents that are not installed are listed with how to install them.

npx ai-scaffolder adopt ./my-repo

Windows: the same command works in PowerShell or cmd. Afterwards use .\.ai\sdlc.cmd where the steps say ./.ai/sdlc.

The whole workflow, step by step

  1. See what it would do

    A dry run. It lists what it found in your repository, the gates it will run (your own scripts), what it cannot cover, and every file it would write. Nothing is written.

    npx ai-scaffolder adopt ./my-repo
  2. Write it

    Adds the .ai/ folder and one marked block in AGENTS.md. A file of yours is never overwritten: if it already exists and differs, it is kept and listed.

    npx ai-scaffolder adopt ./my-repo --write
  3. Record the starting line

    Run every check once and write down what passes today. Then commit .ai/ together with baseline.json. An existing node_modules or virtual environment is used as it is, never wiped.

    cd my-repo
    ./.ai/sdlc doctor      # are the tools installed?
    ./.ai/sdlc setup       # install dependencies
    ./.ai/sdlc baseline    # run every gate once, record what passes
  4. Let an agent describe the repository (recommended)

    An agent drafts a map of the code and its conventions, folding in any CLAUDE.md or .cursor rules you already have. The tool then checks every path and command the draft cites against your repository. You review the draft: it stays marked Draft until you do.

    ./.ai/sdlc onboard
  5. Build a feature, proven

    Write a spec (or draft one from a requirements document), let an agent implement it, and the same checks decide whether it is done. Nothing is ever committed for you.

    ./.ai/sdlc new export-csv           # or: ./.ai/sdlc spec requirements.pdf
    ./.ai/sdlc implement FEAT-001       # an agent writes tests and code, the loop proves it
    ./.ai/sdlc verify                   # nothing that passed on day one may fail

What “done” means for existing code

Existing code is rarely green, so the bar is the day you adopted it, not perfection.

How each check is judged against the baseline
At adoptionNowResult
passedpassesPass
passedfailsFAIL: a regression, it blocks
failedfailsKnown warning: it does not block, and it is not the agent’s job
failedpassesNow passing: lock it in with `baseline --tighten`
  • The baseline is per check, not per violation: a check that was already red can get worse without being noticed. Tighten as checks turn green.
  • Record the baseline where you verify. A check that passes on your laptop but fails in CI would look like a regression there.
  • Secrets already in the repository are recorded as known (their text is never copied); a new one fails the secrets check.

What it finds in your repository

It only proposes a check when your repository defines the command itself, and says where it found it. Nothing is guessed.

  • package.json scripts lint, type-check, test, build (npm, pnpm, yarn or bun, by lockfile)

    node.lint, node.types, node.test, node.build

  • pyproject.toml, requirements files or setup.py with ruff, flake8, mypy or pytest (also Poetry and uv)

    python.ruff, python.mypy, python.pytest

  • A Makefile with lint, test or build targets, when there is no Node or Python project

    make.lint, make.test, make.build

  • Anything else (Go, Rust, Java …)

    Listed as “not covered”; add its commands as gates in a settings file

Scripts that never end (--watch) and the npm “no test specified” placeholder are not made checks, and the report says so.

What it writes: a worked example

This sample repository has a Node app, a Python API, a CLAUDE.md and a CI workflow. The result below is produced live by the same engine the command uses.

The checks found in the sample repository and where each came from
StageCheckRunsFound in
staticnode.lintnpm run lintpackage.json scripts.lint: eslint .
staticnode.typesnpm run type-checkpackage.json scripts.type-check: tsc --noEmit
staticapi.ruffruff check . (in api)ruff config in api/pyproject.toml
unitnode.testnpm run testpackage.json scripts.test: vitest run
unitapi.pytestpytest -q (in api)pytest config found
buildnode.buildnpm run buildpackage.json scripts.build: next build
securityrepo.secretspython3 .ai/sdlc.py secretsbuilt in

Not covered (it will not pretend)

  • Existing CI (.github/workflows/ci.yml) is left alone. It does not run the baseline-aware `verify`; add a job that does (see .ai/README.md).

31 files, all inside .ai/ except one marked block in AGENTS.md. Open any of them:

.ai/README.md
# .ai/: the AI operating system of this repository

Scaffolder added this folder to an existing project (`scaffolder adopt`). It does not change your code, your dependencies or your CI.
It gives people and AI agents one shared definition of "done" that is **checked, not claimed**.

```
.ai/
  sdlc.json               the loop's configuration: gates, setup, integrity, agent (agents may not edit it)
  sdlc  sdlc.cmd  sdlc.py the runner (standard-library Python 3.9+): ./.ai/sdlc, on Windows .\.ai\sdlc.cmd
  baseline.json           which gates passed and failed on adoption day (made by `sdlc baseline`; commit it)
  secrets.baseline.json   secret-like strings that were already in the repository on adoption day
  context/commands.md     the commands this repository defines, and where each was found
  context/architecture.md a map of the code, drafted by `sdlc onboard` and reviewed by a person
  rules/conventions.md    what the code does by convention, drafted the same way
  rules/                  how to work here: short, imperative
  skills/                 step-by-step playbooks an agent loads for that kind of work
  prompts/                templates the loop fills in and sends to the agent
  specs/                  one folder per feature: prd.md + acceptance.json
  evidence/               run output: logs, results.json, report.md (gitignored)
```

## First time (about five minutes)

1. `./.ai/sdlc doctor`: are the tools this repository needs installed?
2. `./.ai/sdlc setup`: install dependencies. An existing `node_modules` or virtual environment is used as it is, never wiped.
3. `./.ai/sdlc baseline`: run every gate once and record what passes today. Then **commit `.ai/` including `baseline.json`**.
4. `./.ai/sdlc verify`: the command to run from now on. Right after the baseline it passes by definition.
5. (optional, worth it) `./.ai/sdlc onboard`: an agent reads the repository and drafts `context/architecture.md` and `rules/conventions.md`, folding in any `CLAUDE.md`, `.cursor/rules` or
   similar guidance that was already here. The tool then checks every path the draft cites, every `npm run` / `make` / `sdlc` command it names, and that every convention points at code. It cannot check that
   the description is *right*: read it, correct it, set `Status: Reviewed`, and commit. Every later agent run reads these files first.

## What "done" means here

Existing code is rarely green, so "done" is not "everything passes". It is **nothing that passed on adoption day fails now**, plus every acceptance criterion of the feature at hand:

- A gate that passed at the baseline must still pass. If it fails, the change broke something: `FAIL`.
- A gate that already failed at the baseline is shown as `WARN` (known). It does not block and it is not the agent's job, unless the feature is about it.
- When a known failing gate starts to pass, `verify` says so. `./.ai/sdlc baseline --tighten` locks the gain in, so it cannot fall back unnoticed.
- The baseline is per gate, not per violation: a gate that was already red can get worse without `verify` noticing. Tighten as gates turn green.
- **Record the baseline where you verify.** A gate that passes on your laptop but fails in CI (a missing tool, a different OS) would show up as a regression there. If CI is the judge, run `baseline` in CI's environment, or fix the difference first.

## Gates (what runs)

Defined once in `.ai/sdlc.json` (stages: `static → unit → build → contract → facts → security`). They are the repository's own commands; see `context/commands.md` for what each one runs and where it was found.
A failing required gate stops the run at the end of its stage (`loop.failFast`), so the agent gets one focused problem.

## Features: spec, then code, then proof

```bash
./.ai/sdlc new user-login               # an empty spec to fill in (prd.md + acceptance.json)
./.ai/sdlc spec requirements.pdf        # or: an agent drafts it from a document (.pdf .docx .md .txt); YOU review it
./.ai/sdlc implement FEAT-001           # an agent writes tests and code; the loop proves it; it never commits
```

`prd.md` lists acceptance criteria (`AC-001` ...); `acceptance.json` maps each to checks. Verification fails if a criterion has no check.
Check types: `cmd` (run a command, usually ONE named test), `file` (exists, contains), `http` (needs a running app, see below).
A check that cannot run here is reported as `SKIP`, never as pass.

## Run the app for facts (optional)

By default the app is not started (`runtime.mode` is `none`), so facts are `cmd` and `file` checks. To check HTTP behaviour against the live app,
declare how to start it in `.ai/sdlc.json` (a human decision: agents may not edit that file):

```json
"runtime": {
  "mode": "local",
  "targets": { "web": "http://127.0.0.1:3000" },
  "local": {
    "provides": ["web"],
    "services": [
      { "name": "web", "cwd": ".", "cmd": "npm run start -- --port 3000", "env": {}, "pathPrepend": [], "healthUrl": "http://127.0.0.1:3000/", "startTimeoutSeconds": 90 }
    ]
  }
}
```

Then an `http` check may use `"target": "web"`. (`"mode": "docker"` runs `runtime.docker` with its own compose project name, so it never touches your development stack.)

## The healing loop (`./.ai/sdlc loop`)

```
verify -> green? -> done (exit 0)
   +-> failed: same failure 2 times in a row -> stop, ask a human (exit 3)
               5 iterations used                        -> stop (exit 1)
               otherwise: heal prompt + evidence -> agent (or you) fixes the CODE -> integrity check (exit 4 if protected files changed) -> verify again
```

Protected for agents: `.ai/sdlc.json`, `.ai/sdlc*`, `.ai/baseline.json`, `.ai/secrets.baseline.json`, `.github/workflows/`; while healing also `.ai/specs/`.
Guarded (an agent may change them, but every change is listed in the report):

- `api/pyproject.toml`
- `eslint.config.mjs`
- `tsconfig.json`

## Your CI

Your existing CI was left alone. It does not know about the baseline, so add a job that does:

```yaml
name: sdlc-verify
on: [pull_request]
jobs:
  verify:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      # install the toolchains this project needs here, exactly as your other workflows do
      - run: ./.ai/sdlc setup
      - run: ./.ai/sdlc verify
```

(Workflows are protected from agents by design; a human adds this one.)

## Configure

| What | Where |
|---|---|
| Add, drop or change a gate | `gates` in `.ai/sdlc.json` (`id`, `stage`, `cwd`, `cmd`, `required`, `timeoutSeconds`) |
| Which AI tool | `./.ai/sdlc agent` lists them (installed or not) and saves your choice in `.ai/agent.local.json` (not committed) |
| Make skips fatal | `facts.strictSkips: true` |
| Loop budget | `loop.maxIterations`, `loop.noProgressLimit` |
| Re-detect after changing the repository | run `scaffolder adopt` again: it adds files that are missing and never overwrites yours (`--force` overwrites the generated ones) |

Good to know

  • Your CI is left alone. It does not know about the baseline; the generated .ai/README.md has the small job to add.
  • Existing agent files stay. CLAUDE.md, .cursor/rules and similar are pointed to, never replaced. Claude Code reads CLAUDE.md, so add the line @AGENTS.md to it.
  • Agents are fenced in. They may not edit the checks, the baseline, your workflows or (while fixing) the specification; the loop stops if they do.
  • Running it again is safe. Nothing changes when nothing changed, and files you edited are kept.
  • Tested on Node and Python projects, throwaway repositories and this tool’s own repository. Not yet on Windows, and not on third-party repositories.
  • Starting a brand-new project instead? Use the New project page.