# Functional Minimalism

**Design around the task. Keep the product’s character.**

Functional Minimalism gives coding agents a portable screen brief, the project’s own design system and a way to check the rendered result.

## Why

A person should be able to recognize the object, action and outcome without reading an introduction. The harness asks an agent to establish that hierarchy before adding words or features.

[Functional minimalism](references/functional-minimalism.md) is our practical philosophy, inspired by Dieter Rams's principles. Reduce the effort needed to understand and act. Preserve labels, meaningful content, prices, permissions and recovery. Each product keeps its own character.

## What

A local design harness with versioned design packs, composition patterns, screen contracts, scoped design memory, and source/rendered-evidence checks. Your coding agent performs the design, browser work and repair; Functional Minimalism supplies context and checks. The harness CLI itself makes no model calls, uses no credentials, and has no npm dependencies or telemetry. The optional prompt lab calls a host-configured free connector when available, or the provider a visitor connects.

**v1.0.0** adds local design system discovery, explicit pack acceptance, copy review and a responsive comparison demo. Run `npm run evaluate` for the offline evaluation. Install from source.

[Source](https://github.com/Automatron-workflows/functional-minimalism) · [Contribute](CONTRIBUTING.md) · [Run a paired experiment](docs/EXPERIMENT.md)

The [public demo](https://automatron-workflows.github.io/functional-minimalism/) is hosted on GitHub Pages and opens without an account. Its route continues into `/demo/`. The recorded runs need no key. A host can deploy the included free connector so visitors also need no key; otherwise live generation uses a visitor key from OpenAI, Anthropic or OpenRouter. The source ZIP is also available from the workshop and offline preview. The separate Higgsfield draft is not part of this public release.

## Try the harness in a minute

Open the [interactive workshop](https://automatron-workflows.github.io/functional-minimalism/demo/workshop.html) without a provider key, choose **Discover**, **Approve**, or **Organize**, then select **Get screen brief**. Inspect, copy, or download the brief. It includes actual component mappings, essential information, and required states.

To try memory, accept a correction in **Design memory**, switch screens, and get another brief. Project decisions carry over; screen-only decisions do not. Starter exports use the paths installed by `setup ../my-app`. They do not write memory into your local project.

## Set up your first screen

Clone [the repository](https://github.com/Automatron-workflows/functional-minimalism), or download and extract `functional-minimalism-source.zip`. From the `functional-minimalism` folder, with Node 18.16 or newer:

```sh
node bin/functional-minimalism.mjs setup ../my-app --template discovery --client both
node bin/functional-minimalism.mjs doctor --project ../my-app
```

Choose `discovery`, `invoice` or `project`; agent adapters are `codex`, `claude` or `both`. Replace `../my-app` with your new project's path.

Setup installs the Studio reference components, pinned pack, workflow, design rules, Rams reference, empty decision memory, a project-scoped screen contract, and `.design-harness/START_HERE.md`. It appends bounded blocks to agent instructions, preserving existing content. Existing harness installations and conflicting component files are refused.

Open the target project in your coding agent and ask:

> Build the screen described in `.design-harness/START_HERE.md`. Follow `.design-harness/WORKFLOW.md`. Render and exercise the result, repair findings, and report any verification limits.

The setup creates context and reusable components, not a running application. The host must load its instruction files; `doctor` cannot observe whether it did. Review the starter contract before building a real product.

## Use your existing design system

The [architecture guide](docs/ARCHITECTURE.md) explains how task scope, component adapters, compact briefs, rendered evidence and accepted memory work together. Start with the usable object and action; justify features before generating explanatory copy.

Inspect the existing project and prepare a proposal. Review inferred mappings, unresolved tokens, states and references using the [format guide](docs/FORMAT.md). Edit the proposal before accepting it. For manually authored packs, omit `--accept`.

```sh
node bin/functional-minimalism.mjs inspect --project ../existing-app
node bin/functional-minimalism.mjs propose-pack --project ../existing-app --out ./my-pack.json
# Review and edit my-pack.json first
node bin/functional-minimalism.mjs init ../existing-app --pack ./my-pack.json --accept --client both
node bin/functional-minimalism.mjs brief ./my-screen.json --project ../existing-app
```

Do not install Studio over an established design system. Custom packs keep their own palette, density, typography and behavior. A normalized token-map importer exists; live Figma/Code Connect import and an Alps pack are pending actual integration and source material.

## Connect an existing React stack

```sh
node bin/functional-minimalism.mjs inspect-react --project ../existing-app
node bin/functional-minimalism.mjs connect-react --project ../existing-app --ui mui
node bin/functional-minimalism.mjs brief ./my-screen.json --compact --project ../existing-app
```

Use this after `init --pack` with the application's own component mappings. Choose the adapter detected in that application; `mui` is an example. `react-adapters` lists all 13 adapters: nine UI systems and four supporting libraries. Connections preserve declared versions, reject ambiguous selections and detect relevant dependency/config drift. They provide implementation context, not installed components or certified runtime compatibility. No packages are installed or executed. See [the adapter boundaries](docs/ARCHITECTURE.md#react-integration).

For new screens, a `surface` plan records primary, secondary and omitted features with task reasons, plus control names and text/icon choices. `essentialByState` keeps required information visible through confirmation and other states. The [appliance contract](examples/appliance.screen.json) demonstrates the planning format; it is not a running timer app.

## Carry a decision forward

```sh
node bin/functional-minimalism.mjs remember --project ../my-app \
  --scope project --target my-app \
  --rule "Keep unfamiliar actions visibly labelled." \
  --reason "Explicit user feedback on navigation." --accept
node bin/functional-minimalism.mjs brief --compact --project ../my-app
```

Use the `projectId` returned by setup as the target. Without `--accept`, a decision stays proposed and is excluded from briefs. Accepted memory supports global (`*`), pack, project, and screen (`project-id/screen-id`) scopes. `--supersedes <id>` replaces a decision only within the same scope and target. After editing your contract, changing accepted decisions or connecting components, run `node bin/functional-minimalism.mjs refresh --project ./my-app`. `doctor` flags missing or outdated starters. Refresh restores missing files and preserves hand edits. For an older or edited starter, compare `brief --compact` with your copy and move it aside before refreshing.

## See it work

```sh
npm run build
npm run dev
```

Open **http://127.0.0.1:4178/demo/**. Try **Review payment**, then **Back to invoice**. Compare the model’s first draft (**Before**), freeform rewrite (**HTML pass**) and choice of Atelier components (**After**). **Reference** opens the authored study. The [cross-model audit](docs/MODEL-AUDIT.md) explains the three local trials and the [November archive](https://automatron-workflows.github.io/functional-minimalism/demo/?series=archive).

Choose **Try it** to generate with a configured connector or your provider. Provider charges may apply. No real payment occurs. **Set up** includes the source archive and commands.

The approved components live in [`gallery/templates.json`](gallery/templates.json), a manually reviewed MIT dataset rendered at **http://127.0.0.1:4178/gallery/**. The review loop is deliberate: a generated design becomes a proposal, a person extracts and approves components, and the gallery is versioned. Nothing is trained automatically from an unapproved output.

## Keyless free connector

BYOK is friction. The lab supports a host-configured free connector:

```sh
OPENCODE_API_KEY=... npm run dev
```

The local server exposes a free-model allowlist at `/api/lab`; the browser detects it and shows **Free local connector**. The token stays in Node, never in the page.

For the public GitHub Pages demo, deploy the included Cloudflare Worker once and point `demo/lab-config.json` at it:

```sh
cd worker
npx wrangler secret put OPENCODE_TOKEN
npx wrangler deploy
```

Visitors then generate without a key. The Worker only accepts the free models, caps output, rate-limits by IP in its isolate, and keeps the token secret. See [the connector guide](docs/PUBLIC-CONNECTOR.md). If no connector is configured, the recordings remain available and the visitor can use their own key.

## Time and token usage


Setup emits a compact brief that retains the task, source mappings, component rules and accepted decisions. Use `brief --compact` to preview it and `refresh` to update it. `npm run measure:context` reports exact UTF-8 byte counts for full and compact example briefs. Bytes are not model tokens.

The harness adds context; the intended saving comes from avoiding repeated redesigns. No model benchmark or time-saving percentage is claimed. Follow [the paired experiment](docs/EXPERIMENT.md) to compare real usage and time under equal acceptance criteria.

Live generation makes two requests per model. Only the exact invoice preset receives Atelier layout rules, its fixture, draft-specific findings and the reference stylesheet. Other prompts receive task-neutral design guidance. A failed target stays visible.

`npm run audit:models` renders all eight original outputs and the separate reference at three widths. See the [model audit](docs/MODEL-AUDIT.md) for findings and limits.

`npm run benchmark:lab` measures the historical v0 and v1 prompt variants at 1280 and 390px, writes [the benchmark](docs/BENCHMARK.md) and `docs/benchmark.json`. The v1 after pass averaged **96.2/100** against **77.7** for v0 on the transparent craft heuristic, with 4 of 4 models improving. The heuristic rewards text restraint, one visible primary action, hierarchy, cohesion, whitespace, responsive integrity, facts and contrast. It is not a beauty model; see the benchmark limits.

## Check the result

```sh
npm test
npm run build
npm run check
npm run test:browser
```

The browser runner requires a local Chrome installation and permission to launch it. Set `CHROME_BIN` if needed. It tests the workshop at 390px and 1440px and writes evidence to `artifacts/`. It does not download a browser. See [the verification record](docs/VERIFICATION.md) for actual results and restrictions.

For your own screen, use `src/browser.mjs` to collect each contract state at each viewport and create the documented evidence envelope, then run:

```sh
node bin/functional-minimalism.mjs audit screen.json evidence.json --project ../my-app
```

Checks cover missing essential information, unnamed/clipped controls, overflow, annotated component/variant mismatches, missing primary actions, and state/viewport coverage. Small targets, competing actions and explanatory copy produce review findings. No word reduction can compensate for lost task information.

`check --css path.css` is lexical CSS analysis, not a full parser. Source checks validate paths and recognizable exports, not actual runtime component identity. DOM accessible names use a heuristic, not the full accessible-name algorithm. Caller-supplied evidence is not authenticated. These checks do not certify accessibility, aesthetics or usability.

Pack drift requires review and explicit `pin`. Memory is inspectable JSON, not model training. There is no autonomous repair engine or cross-model study.

Read [workflow](adapters/WORKFLOW.md), [rules](DESIGN_RULES.md), [brand](docs/BRAND.md), [audit](docs/AUDIT-v0.3.md), [commands](docs/CLI.txt), [status](docs/STATUS.md) and [Hardwire reference](references/hardwire.md). The legacy `design-harness.mjs` entry point remains compatible. MIT license.
