Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 108 additions & 86 deletions README.md

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions docs/adr/0007-light-by-default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 7. Light by default, strict where it matters

Date: 2026-11-22 · Status: accepted

## Context

By 0.6 every lane change, however small, needed an acceptance file, a run, a brief, a review
subagent, a review naming the tree and an evidence pack before the Stop gate let the turn end, and
setup asked for design and backend contracts, ctl, journeys, lint guardrails and a checklist first.
Each step had a reason; together they were the kind of process developers abandon. Size and risk
were also mixed: a one-line change to a login check was "small".

## Decision

- One entry, the `workflow` skill (`/workflow`): understand, plan, implement, verify, complete. The
developer describes the change; the skill sizes it, picks the steps and the installed skills, and
says when it will stop to ask.
- Size (judged by the agent from the request) decides planning: Small writes no file, Medium only
`.verify/acceptance.md` (with a short plan when needed), Large a spec with an architecture
section and a task list.
- Risk (computed from the diff by `lib/level.mjs`, shown by `level.mjs`) decides verification:
light (at most 40 lines and 3 files, nothing risky) needs only passing checks; standard adds
acceptance and one independent review; strict (contracts, migrations, sensitive or native paths,
the checks themselves, and, without any config, risky paths and code: auth, payments, permissions,
destructive SQL, raw HTML) adds a deep review with a security pass and merge tier 3.
- The Stop gate, the brief and the evidence pack follow the level. The gate writes the evidence pack
itself when that is all that is missing. Reviews stop after two rounds. The brief asks only for the
reviews the diff needs: code always, screenshots when something visual changed, contract
compatibility, security.
- superpowers and Matt Pocock's skills do brainstorming, planning, TDD, worktrees, debugging,
architecture and code quality; agent-skills is no longer routed. This plugin keeps orchestration,
verification, independent review, evidence and the ratchet.
- `init.mjs` writes a working `.verify/config.json` from the project's existing commands; the full
setup is for when a change needs it.

## Consequences

A light change ends with no review: a small, non-risky bug can merge on its checks alone. The light
limits and the risk heuristics are defaults a project can tune (`risk` in the config); the
heuristics will flag some harmless files (an `author.ts`) as risky, which costs a deeper review, not
a wrong merge. Earlier docs (`flow`, `shared/spec.md`, `shared/tasks.md`) are folded into
`skills/workflow/`.
4 changes: 2 additions & 2 deletions plugins/dx-workflow/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dx-workflow",
"version": "0.6.0",
"description": "A request to a mergeable change with a gate between every step: size the change, spec and tasks for large ones (flow-check), acceptance criteria first, a design contract and a backend contract, checks per lane (frontend on the web or React Native / Expo, backend) including a negative check, independent review, an evidence pack with a computed merge tier, and a Stop gate. Checks are read from the base commit, runs and reviews are bound to a content hash, and changes to the checks themselves are tier 3. Works with Matt Pocock's skills, superpowers and agent-skills for the work inside a step.",
"version": "0.7.0",
"description": "One workflow from request to mergeable change, light by default and strict where it matters: the developer describes the change; it sizes it, computes how strictly to check it from the diff (light, standard, strict), uses superpowers and Matt Pocock's skills inside steps, acceptance criteria first, a design contract and a backend contract, checks per lane (frontend on the web or React Native / Expo, backend) including a negative check, independent review, an evidence pack with a computed merge tier, and a Stop gate. Checks are read from the base commit, runs and reviews are bound to a content hash, and changes to the checks themselves are tier 3. ",
"author": {
"name": "davidxiaodev"
},
Expand Down
2 changes: 1 addition & 1 deletion plugins/dx-workflow/scripts/flow-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const specPathFor = (tasksFile) => tasksFile.replace(/\.tasks\.md$/, ".md");
const read = (p) => readFileSync(p, "utf8");

if (cmd === "spec") {
report("spec", checkSpec(parseSpec(read(path))), `the spec is agreed and complete: write the task list (shared/tasks.md) or, for one pull request, the acceptance: flow-check.mjs acceptance ${rel(path)} --write`);
report("spec", checkSpec(parseSpec(read(path))), `the spec is agreed and complete: write the task list (skills/workflow/large.md) or, for one pull request, the acceptance: flow-check.mjs acceptance ${rel(path)} --write`);
} else if (cmd === "tasks") {
const specFile = specPathFor(path);
if (specFile === path || !existsSync(specFile)) fail(`flow-check: a task list is <spec>.tasks.md next to its spec; no ${rel(specFile)}.`);
Expand Down
164 changes: 164 additions & 0 deletions plugins/dx-workflow/scripts/init.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#!/usr/bin/env node
// Day-one setup: find the apps and services in this repo and the checks they already have, and write
// a minimal .verify/config.json from them. Nothing else is required to start; design contracts,
// screenshots, journeys and checklists are added later, when a change needs them.
//
// node init.mjs [--dry-run] [--force]
//
// It looks at the repo root and one level of apps/, packages/, services/ and the top-level folders:
// package.json web (next, react, vue, svelte, vite, astro, remix, solid…) → frontend lane
// expo / react-native → frontend lane, platform react-native
// express, fastify, koa, hono, nest, a server with no UI → backend lane
// its scripts: typecheck, lint, test (and tsc --noEmit when there is a tsconfig)
// pyproject.toml / requirements.txt → backend lane: ruff, mypy, pytest when configured
// go.mod → backend lane: go vet, go test
// Every lane with a test command also gets the negative check.
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
import { join, relative } from "node:path";
import { gitRoot } from "./lib/verify-config.mjs";

const args = process.argv.slice(2);
const root = gitRoot(process.cwd());
if (!root) fail("init: run this inside a git repository.");
const target = join(root, ".verify", "config.json");
if (existsSync(target) && !args.includes("--force") && !args.includes("--dry-run")) fail(`init: ${relative(process.cwd(), target) || target} exists (use --force to replace it).`);

const WEB = ["next", "react", "react-dom", "vue", "nuxt", "svelte", "@sveltejs/kit", "vite", "astro", "@remix-run/react", "solid-js", "@angular/core", "preact"];
const RN = ["expo", "react-native"];
const SERVER = ["express", "fastify", "koa", "hono", "@nestjs/core", "@hapi/hapi", "restify", "elysia", "@trpc/server", "apollo-server", "@apollo/server"];

const candidates = [".", ...["apps", "packages", "services"].flatMap((d) => subdirs(d).map((s) => `${d}/${s}`)), ...subdirs(".").filter((d) => !["apps", "packages", "services", "node_modules", "docs", "scripts", "e2e", "test", "tests"].includes(d))];
const pm = existsSync(join(root, "pnpm-lock.yaml")) ? "pnpm" : existsSync(join(root, "yarn.lock")) ? "yarn" : existsSync(join(root, "bun.lockb")) || existsSync(join(root, "bun.lock")) ? "bun" : "npm";
const lanes = {};
const found = [];

for (const dir of [...new Set(candidates)]) {
const abs = join(root, dir);
const node = readJsonFile(join(abs, "package.json"));
if (node) addNode(dir, node);
else if (existsSync(join(abs, "pyproject.toml")) || existsSync(join(abs, "requirements.txt"))) addPython(dir);
else if (existsSync(join(abs, "go.mod"))) addGo(dir);
}
// In a monorepo (workspaces, pnpm-workspace.yaml, turbo.json, nx.json) the root package.json is the
// workspace, not an app: its files overlap every app's, and its scripts run every app's checks again.
for (const [name, lane] of Object.entries(lanes)) if (lane.atRoot && Object.keys(lanes).length > 1) delete lanes[name];
for (const lane of Object.values(lanes)) delete lane.atRoot;
const kept = new Set(Object.keys(lanes));
found.splice(0, found.length, ...found.filter((f) => kept.has(f.split(" ")[0])));

if (!Object.keys(lanes).length) fail("init: found no package.json, pyproject.toml, requirements.txt or go.mod to build lanes from. Write .verify/config.json from the plugin's shared/verify.config.json.");

const config = { lanes };
const text = JSON.stringify(config, null, 2) + "\n";
console.log(`init: ${found.length} lane(s):`);
for (const f of found) console.log(`- ${f}`);
if (args.includes("--dry-run")) {
process.stdout.write(text);
process.exit(0);
}
mkdirSync(join(root, ".verify"), { recursive: true });
writeFileSync(target, text);
const gi = join(root, ".gitignore");
const ignore = existsSync(gi) ? readFileSync(gi, "utf8") : "";
const missing = [".verify/*", "!.verify/config.json"].filter((l) => !ignore.split("\n").includes(l));
if (missing.length) writeFileSync(gi, `${ignore}${ignore && !ignore.endsWith("\n") ? "\n" : ""}${missing.join("\n")}\n`);
console.log(`init: wrote .verify/config.json${missing.length ? " and .gitignore lines" : ""}.`);
console.log("Next: run `node <plugin>/scripts/run-verify.mjs --config working` once on the unchanged code; every check should pass. Commit .verify/config.json.");
console.log("Later, only when a change needs it: docs/design.md and screenshots (frontend setup.md), docs/backend.md (backend setup.md), sensitive paths, docs/checklist.md.");

function addNode(dir, pkg) {
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
const has = (list) => list.some((d) => d in deps);
const scripts = pkg.scripts ?? {};
const kind = has(RN) ? "rn" : has(WEB) ? "web" : has(SERVER) || pkg.main || scripts.start || existsSync(join(root, dir, "tsconfig.json")) ? "backend" : null;
if (!kind) return;
const run = (name) => (pm === "npm" ? `npm run ${name}` : `${pm} run ${name}`);
const pick = (...names) => names.find((n) => scripts[n] && !/no test specified/.test(scripts[n]));
const checks = [];
const typecheck = pick("typecheck", "type-check", "types", "check-types", "tsc");
if (typecheck) checks.push({ name: "types", run: run(typecheck) });
else if (existsSync(join(root, dir, "tsconfig.json"))) checks.push({ name: "types", run: "npx tsc --noEmit" });
const lint = pick("lint");
if (lint) checks.push({ name: "lint", run: run(lint) });
const test = pick("test:unit", "test");
if (test) checks.push({ name: "unit", run: run(test) }, { name: "negative", negative: { test: run(test) } });
for (const c of checks) if (dir !== ".") c.cwd = dir;
for (const c of checks) if (c.negative && dir !== ".") c.negative.cwd = dir;
const name = laneName(dir, kind === "backend" ? "api" : kind === "rn" ? "app" : "web");
const prefix = dir === "." ? "" : `${dir}/`;
lanes[name] =
kind === "backend"
? { kind: "backend", files: [`${prefix}**/*.{ts,js,mjs,cjs,mts}`, ...(dir === "." ? [] : [`${prefix}package.json`])], checks }
: kind === "rn"
? { kind: "frontend", platform: "react-native", files: [`${prefix}**/*.{ts,tsx,js,jsx}`, `${prefix}app.json`, `${prefix}app.config.{js,ts}`, `${prefix}ios/**`, `${prefix}android/**`], native: [`${prefix}app.json`, `${prefix}app.config.{js,ts}`, `${prefix}eas.json`, `${prefix}ios/**`, `${prefix}android/**`], checks }
: { kind: "frontend", files: [`${prefix}**/*.{tsx,jsx,ts,js,vue,svelte,astro,css,scss}`], checks };
const workspace = pkg.workspaces || existsSync(join(root, "pnpm-workspace.yaml")) || existsSync(join(root, "turbo.json")) || existsSync(join(root, "nx.json"));
if (dir === ".") Object.assign(lanes[name], { ignore: ["**/node_modules/**", "**/dist/**", "**/build/**", "**/.next/**"], atRoot: Boolean(workspace) });
found.push(`${name} (${kind === "rn" ? "React Native / Expo" : kind === "web" ? "web frontend" : "Node backend"}, ${dir === "." ? "repo root" : dir}): ${checks.map((c) => c.name).join(", ") || "no checks found: add them to the lane"}`);
}

function addPython(dir) {
const abs = join(root, dir);
const py = [readText(join(abs, "pyproject.toml")), readText(join(abs, "requirements.txt")), readText(join(abs, "requirements-dev.txt"))].join("\n");
const checks = [];
if (/\bruff\b/.test(py)) checks.push({ name: "lint", run: "ruff check ." });
if (/\bmypy\b/.test(py)) checks.push({ name: "types", run: "mypy ." });
if (/\bpytest\b/.test(py) || existsSync(join(abs, "tests"))) checks.push({ name: "unit", run: "pytest -q" }, { name: "negative", negative: { test: "pytest -q" } });
for (const c of checks) {
if (dir !== ".") c.cwd = dir;
if (c.negative && dir !== ".") c.negative.cwd = dir;
}
const name = laneName(dir, "api");
lanes[name] = { kind: "backend", files: [`${dir === "." ? "" : `${dir}/`}**/*.py`], checks };
found.push(`${name} (Python backend, ${dir === "." ? "repo root" : dir}): ${checks.map((c) => c.name).join(", ") || "no checks found: add them to the lane"}`);
}

function addGo(dir) {
const cwd = dir === "." ? {} : { cwd: dir };
const checks = [
{ name: "vet", run: "go vet ./...", ...cwd },
{ name: "unit", run: "go test ./...", ...cwd },
{ name: "negative", negative: { test: "go test ./...", ...cwd } },
];
const name = laneName(dir, "api");
lanes[name] = { kind: "backend", files: [`${dir === "." ? "" : `${dir}/`}**/*.go`], checks };
found.push(`${name} (Go backend, ${dir === "." ? "repo root" : dir}): vet, unit, negative`);
}

function laneName(dir, fallback) {
const base = dir === "." ? (Object.keys(lanes).length ? "root" : fallback) : dir.split("/").pop().toLowerCase().replace(/[^a-z0-9-]/g, "-");
let name = base;
for (let i = 2; lanes[name]; i++) name = `${base}-${i}`;
return name;
}

function subdirs(d) {
try {
return readdirSync(join(root, d), { withFileTypes: true })
.filter((e) => e.isDirectory() && !e.name.startsWith("."))
.map((e) => e.name);
} catch {
return [];
}
}

function readJsonFile(p) {
try {
return JSON.parse(readFileSync(p, "utf8"));
} catch {
return null;
}
}

function readText(p) {
try {
return readFileSync(p, "utf8");
} catch {
return "";
}
}

function fail(message) {
console.error(message);
process.exit(2);
}
29 changes: 29 additions & 0 deletions plugins/dx-workflow/scripts/level.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env node
// What does the current change need? Prints the verification level (light, standard, strict) and why.
//
// node level.mjs [--json]
//
// light: the checks must pass, nothing else. standard: acceptance, one independent review, evidence.
// strict: also a deep review with a security pass, and the owner approves the merge.
import { changeLevel } from "./lib/level.mjs";
import { gitRoot, loadConfig } from "./lib/verify-config.mjs";

const root = gitRoot(process.cwd());
const cfg = root && loadConfig(root);
if (!cfg) {
console.error("level: no .verify/config.json here (run init.mjs first).");
process.exit(2);
}
const l = changeLevel(cfg);
if (process.argv.includes("--json")) console.log(JSON.stringify(l, null, 2));
else {
console.log(`level: ${l.level} · ${l.files} lane file(s), ${l.lines} changed line(s)${l.lanes.length ? ` · lanes: ${l.lanes.join(", ")}` : ""}`);
for (const r of l.reasons) console.log(`- ${r}`);
console.log(
{
light: "needs: the lane checks pass (run-verify.mjs). No acceptance file, no review.",
standard: "needs: .verify/acceptance.md, run-verify.mjs, one independent review (review-brief.mjs). The evidence pack is made for you.",
strict: "needs: as standard, with a deep review and a security pass; merge tier 3 (the owner approves).",
}[l.level],
);
}
4 changes: 3 additions & 1 deletion plugins/dx-workflow/scripts/lib/flow.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const field = (text, name) => new RegExp(`^${name}:\\s*(.+)$`, "im").exec(text)?
export function parseSpec(text) {
const goals = items(section(text, "Goals"), "S");
const nonGoals = (section(text, "Non-goals") ?? []).filter((l) => /^\s*-\s*\S/.test(l) && !/^\s*-\s*</.test(l));
const architecture = (section(text, "Architecture") ?? []).filter((l) => l.trim() && !/^\s*</.test(l));
const decisions = items(section(text, "Decisions"), "D");
const questions = items(section(text, "Open questions"), "Q").map((q) => ({
...q,
Expand All @@ -35,7 +36,7 @@ export function parseSpec(text) {
refs: [...new Set([...c.text.matchAll(/\bS\d+\b/g)].map((m) => m[0]))],
proof: /·\s*proof:\s*\S/i.test(c.text),
}));
return { title: /^#\s*Spec:\s*(.+)$/m.exec(text)?.[1].trim() ?? null, status: field(text, "Status"), goals, nonGoals, decisions, questions, criteria };
return { title: /^#\s*Spec:\s*(.+)$/m.exec(text)?.[1].trim() ?? null, status: field(text, "Status"), goals, nonGoals, architecture, decisions, questions, criteria };
}

/** Problems that keep a spec from gating into acceptance and tasks. */
Expand All @@ -44,6 +45,7 @@ export function checkSpec(spec) {
if (!/^agreed$/i.test(spec.status ?? "")) p.push(`Status is "${spec.status ?? "missing"}": the user agrees the spec before building ("Status: agreed").`);
if (!spec.goals.length) p.push("no goals (## Goals with - S1 …): what outcome makes this worth doing?");
if (!spec.nonGoals.length) p.push("no non-goals (## Non-goals): say what this does not do, so nobody builds it.");
if (!spec.architecture.length) p.push("no architecture (## Architecture): the modules or screens involved, their interfaces, the data and who owns it; a few lines.");
for (const q of spec.questions.filter((q) => !q.resolved)) p.push(`${q.id} is open: answer it (→ D<n>), or write "· deferred: <why it is safe to build without it>".`);
if (!spec.criteria.length) p.push("no acceptance criteria (## Acceptance with - A1 … (S1) · proof: …).");
const goalIds = new Set(spec.goals.map((g) => g.id));
Expand Down
Loading
Loading