Port or migrate TypeScript/JavaScript, Python, C, Ruby, PHP, Swift, Rust, Java, Kotlin, C# or PowerShell code to Go with the go-anything CLI or MCP tools, one unit at a time, from a single function or class up to a whole library - analyze, bridge one unit, record the original's behavior, write the Go port, build, diff, bench, fuzz, shadow, enable and gate it. Use when asked to rewrite, port or migrate such code to Go, to plan such a migration, to check that a Go port behaves the same as the o...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Go Anything?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/boracomet-go-anything)
---
name: go-anything
description: Port or migrate TypeScript/JavaScript, Python, C, Ruby, PHP, Swift, Rust, Java, Kotlin, C# or PowerShell code to Go with the go-anything CLI or MCP tools, one unit at a time, from a single function or class up to a whole library - analyze, bridge one unit, record the original's behavior, write the Go port, build, diff, bench, fuzz, shadow, enable and gate it. Use when asked to rewrite, port or migrate such code to Go, to plan such a migration, to check that a Go port behaves the same as the original, or to switch a ported unit on for the original's callers.
---
# Migration to Go with go-anything
go-anything gives you ground truth; you write the Go. Port one unit at a time, and call a unit's
port done only when `gate` passes. A recording of the original's behavior is the proof, not your
tests.
This skill covers the unit loop, with Python and TypeScript/JavaScript in its examples (each other
source language has its file under `languages/`), the commands that surround it, and whole apps
(the `app` commands and `obligations`, at the end).
**A new app in Go** (nothing to port: the user wants a new command-line tool): read
[new-app.md](new-app.md) and follow it. The user's approved cases stand in for the original:
`go-anything new` starts the app with a spec, the user approves its cases, and `spec check`
decides when it is done.
**A Laravel app to Laravel Go** (the official `go.laravel.com` framework, route by route): read
[laravel.md](laravel.md) and follow it.
**Check the status first.** Read `docs/STATUS.md` in the go-anything repository before you rely on a
command or a check. Something it does not list as working is not built yet: say so to the user,
and never write that a command works or that a check passed unless you ran it in this session.
The language is detected; `--lang python` or `--lang ts` overrides it in `analyze` and `bridge`. The
steps are the same for both languages, the traps differ, and the original's callers keep their API.
**Before writing a port, read the file for the unit's language:**
[languages/python.md](languages/python.md) and
[languages/typescript.md](languages/typescript.md). They say how the constructs map to Go and which
traps made recorded cases differ.
## Tools
The `go-anything` CLI, or the same steps as MCP tools (see "MCP" below). Install it with
`go install github.com/boracomet/go-anything/cmd/go-anything@latest` (`@latest` works once a version
is published; `docs/install.md` says none has been yet), or from a checkout of the repository with
`go install ./cmd/go-anything`. It needs Go 1.25 or newer and a C compiler that
cgo can use, because every port module is built as a C shared library; `python3` and `node` are
needed only for the language you port. When a step fails because a tool is missing, run
`go-anything doctor`: it checks each one and prints the command that fixes it.
## MCP
`go-anything mcp` serves the steps below as MCP tools of the same names: `analyze`, `bridge`,
`refresh`, `record`, `build`, `diff`, `profile`, `go`, `enable`, `disable`, `report`, `bench`,
`fuzz`, `shadow`, `package`, `gate`, `selftest`, `map`, `log`, `obligations`, `obligations_check`, `obligations_fallbacks` and `rules`, and for a whole app
`app_record`, `app_replay`, `app_drift`, `app_front_door`, `app_wire` and `app_lift`, and for a new app `new` and
`spec_check` (they take the app's folder as `dir`). A tool's arguments are the CLI's
flags with underscores (`float_tolerance` for `--float-tolerance`). The path argument of a
per-module tool is called `module`; it is `root` for `analyze`, `bridge`, `rules`, `profile` and
`go` (`bridge` also takes `unit`; `profile` and `go` take the workload as `command`, the words after
`--`), and `repo` for `map`, `log`, `obligations`, `obligations_check`, `obligations_fallbacks`, `app_record`, `app_replay`, `app_drift`, `app_front_door`, `app_wire` and `app_lift` (`app_record` takes the original's
command as `run`, `app_wire` takes `unit`). The verdict tools, `gate`, `diff`, `app_replay` and `spec_check`, answer with an error result when
the verdict says no. `go-anything setup` registers the server and this skill with Claude Code,
Codex, Cursor, Gemini CLI and OpenCode; restart the agent afterwards. If the MCP tools are not
available, use the CLI.
## 0. Rules first
Before you write any code, run `go-anything rules <repo>` and follow every rule it lists: behavior
the user already corrected in an earlier unit. Each time the user corrects how the port behaves,
add it right away with `go-anything rules <repo> --add "<the rule, in one sentence>"`, so the next
unit and the next agent keep it. The rules are kept in `go/RULES.md`.
## The hot path in one command
When the user wants a program faster rather than a whole migration, start from a real workload:
```sh
go-anything profile <repo> -- python3 app.py # hot functions, their callers, loops to batch
go-anything go <repo> --agent claude -- python3 app.py
```
`profile` runs a real workload under the language's own profiler, for Python, TypeScript/JavaScript,
Ruby and Java; it refuses C, Rust, PHP, Swift, Kotlin, C# and PowerShell workloads before running them.
`go` profiles the workload, bridges the outermost portable hot function into
`<repo>/go/<function>-go`, records it with the calls the workload makes, writes `TASK.md`, hands the
port to `--agent` for up to `--rounds` turns, then builds, diffs, gates and benches it, and switches
it on only when every case matches, gate passes and the port is not slower as its callers call it.
Without `--agent` it stops at `waiting_for_port`: port `port/port.go` as `TASK.md` says and run the
same command again; finished steps are kept. When it stops at `slower`, read its sentence about
where the speed is before porting anything else. `go` asks no approval of a plan: use it when the
user asked for this one function, and the plan below for anything larger.
## 1. Plan, then stop
```sh
go-anything analyze <repo> -o plan.md # for people
go-anything analyze <repo> --json # for you: schema go-anything/analyze@1
go-anything analyze <repo> --whole-app # a whole app: entry points, every dependency, pieces, decisions
```
To see everything the original offers (not only what the unit you port exports), run
`go-anything obligations <repo>` (`--json` for you: schema go-anything/obligations@1; `--write`
saves `go/OBLIGATIONS.json`). Only the export family can be `complete`; commands, flags, routes
and environment variables are what the detectors recognised, and a family no detector reads is
`unknown`. A listed obligation is not a ported one, and an empty family is not proof of nothing.
`go-anything obligations <repo> --evidence` links each obligation to the recorded cases that exercise
it and lists the ones no case does, each with a candidate input (`--json`: schema
go-anything/evidence@1; `--write` also saves `go/OBLIGATIONS.evidence.json`); it only reads recorded
files and runs nothing. `go-anything obligations <repo> --check` says what blocks the whole-app lift
and how to unblock it (`--json`: schema go-anything/standing@1), and exits 1 while anything does:
obligations no recorded case exercises, families that are not complete and nobody attested, expected
files with a `...` line, and fallbacks nothing explains. `go-anything obligations fallbacks <journal>...
--repo <repo>` sorts what a generated front door handed back to the original (`--write` stores the ones
outside the registry in `go/obligations-fallbacks.jsonl`, `--inputs <file>` writes `app record` inputs).
**`obligations waive`, `obligations attest` and the bindings in `go/obligations-bindings.toml` are the
user's decisions: each writes an ADR in `go/DECISIONS.md`. Never run them, or write a binding, on your
own to make `--check` pass; there is no tool for them. Ask.**
- Present the `start_here` units (the best first ports) and the order by package and wave.
- Call out units marked `keep` (UI code: it stays in the source language), `blocked` units and
their reason, and dependencies whose Go fit is `none`, `partial` or `unknown`. Do not hand-roll a
missing library silently: flag it.
- `--whole-app` adds the `whole_app` section: the app's shape and entry points, every dependency
(imported or declared) with its Go fit, the pieces in port order (units that import each other
are one piece) and numbered decisions, each with a recommended answer. Put the decisions to the
user before porting; do not answer them yourself.
- `analyze` may name a WASI module as a unit's bridge. Only the C shared library bridge is built:
wasm is planned, so bridge such a unit as a C shared library.
- `record` compares what a function returns or throws, the arguments after the call and what it
printed ("What a call is compared on" in `docs/how-it-works.md`). `bridge` keeps an export in the
original, with its reason, when it cannot cross the bridge or could not be checked: it takes or
returns a function, is a generator, takes `*args` or `**kwargs`, reads the environment, checks
`instanceof` or takes a RegExp. Tell the user which exports stayed and why. Do not bridge them by
editing the recording.
- **Wait for the user's approval of the plan and of the first unit.**
## 2. Port one unit
```sh
go-anything bridge <repo> <unit> # writes <repo>/go/<name>-go/; never overwrites
go-anything record <module> # the original's behavior -> cases.jsonl
```
`<unit>` is a unit id from `analyze` or a source file inside it; `--name` and `--out` change the
module's name and folder. `bridge` prints what to port (functions and classes) and what stays in
the original, each with its reason. `bridge --keep name` keeps one more export by hand; `--exports`
hands it the exports as JSON when the language plugin's types are wrong (an untyped Python
parameter guessed as `float64` loses the difference between `1234567` and `1234567.0`; read the
stubs' types before you write anything).
`record` runs the original in its own runtime on generated inputs (the edge cases of each type and
the semantic traps) and on `--inputs`, and saves what each call returned or threw, its arguments
after the call when they changed, and what it printed, one case per line in `cases.jsonl`, with
`recorded-from.json` next to it. For a function in a file that uses regular expressions it adds
cases for the regex traps (non-ASCII `\w`, `\b` and case folding).
- Give real inputs with `--inputs inputs.jsonl`: one `{"fn": name, "args": [...]}` per line, plus
`"kwargs": {...}` for Python, or `{"class": name, "ctor": [...], "calls": [{"method": name,
"args": [...]}]}` for a class scenario. A file of your own, not the recording. Generated inputs
cannot guess a text format or an untyped Python parameter: on `demo/py-textkit` alone `record`
made one successful call of `title_case`. Recording the calls of the original's own tests
(`--from-tests`) is not built yet; `--inputs` is how to give it the calls a caller makes.
- If the original has no tests, `record` is the characterization suite: keep `cases.jsonl`.
- `--messages` also compares error messages, not only error classes: use it when callers print or
match them. `--no-messages` saves the opposite.
**A port keeps behavior, bugs included.** Port a known bug as it is, and fix it in its own change
once the port's `gate` passes, with each case the fix changes listed in `known-diffs.jsonl` and its
reason, but only after the user says yes (step 3): never to turn a red `diff` or `gate` green. A
change that ports and fixes at once cannot be told apart from a regression.
Write the port in `port/port.go` only, in package `port`. `main.go`, `wire.go`, `goany/` and the
wrapper are generated; `bridge` and `refresh` leave `port/port.go` alone. Put your own tests in
`port/port_test.go`. After you change a signature in `port.go`, run `go-anything refresh <module>`:
it reads the signatures back, so a parameter the port now takes by pointer is changed in place and
written back into the caller's object, and a last parameter `stdout *strings.Builder` prints
through the caller.
Read each risk the plan lists for the unit, at its `file:line`, before you write code. Rules for
the port:
- **Errors.** Return an `error` whose text starts with the original's class, as in
`errors.New("ValueError: size must be positive")`; the wrapper raises that class in the caller's
language (the language file says how names resolve and what `diff` compares). Do not drop an
error (`_ =`, or a call whose error is never checked), and do not `panic` where the original
returns an error. A `panic` is allowed only on a line marked `// INFALLIBLE: <why>`, for a state
the original also treats as impossible. A recorded failing case must exist for every place the
original fails on purpose: add one with `--inputs` when `gate` names it.
- **Output.** What the original prints goes to the `stdout *strings.Builder` the stub receives,
not to the process's standard output: a port that prints directly shows an empty `stdout` and
fails the case.
- **Pure Go.** No `unsafe`, no cgo, no `//go:linkname`, no `plugin`, no `reflect` pointer tricks and
no `os/exec`. A port that runs the original for each call passes every recorded case, and `gate`
refuses it.
- **No recorded answers.** Compute every result. A table of the recorded answers is refused.
- **Integers.** Go's `int64` wraps silently and never panics; Python's `int` never overflows. Check
the range and fail loudly, or use `math/big` where the value can grow, and record the choice with
`rules`.
- **Maps.** Go ranges over a `map` in random order. Where the original's output depends on key
order (a Python `dict`, a JavaScript object or `Map`), use `goany.Map[V]` (insertion order, with
`Set`, `Get`, `Delete`, `Keys` and `All`) or a slice of keys beside the map. Sort the keys where
the original sorts them. A nil map panics on write: `make` it first.
- **Strings.** A Go string is UTF-8 bytes. `len` and `s[i]` count bytes; `range` gives code points.
Python counts code points and JavaScript UTF-16 code units, so convert before you index or slice.
- **Floats** do not print like Python or JavaScript, and Go may fuse `x*y + z` into one operation on
some CPUs. The language files give the formatters and the fix.
- **Nil.** Return an untyped `nil` for no error: a typed nil pointer in an `error` is not `nil`.
- **Regular expressions.** Go's `regexp` has no lookaround and no backreferences, and its `\d`,
`\w`, `\s` and `\b` are ASCII only. Name the Unicode classes (`\p{Nd}`, `\p{L}`) where the
original's engine is Unicode (Python 3), and ask the user for real text the patterns see.
- **Sorting.** `sort.Slice` is not stable and `sort.Strings` compares UTF-8 bytes; Python's
`sorted` is stable and compares code points, and JavaScript's `sort` compares UTF-16 code units.
- More traps, each with the Go that matches the source, are in the language files and in
`docs/pitfalls.md` of the go-anything repository.
- `go test` passing with no tests proves nothing: the recorded cases are the proof. Fix what
`gofmt`, `go vet` and `staticcheck` report instead of silencing it, and tell the user about any
suppression you add.
### Classes and methods
A class of the unit crosses the bridge unless `bridge` says why it stays (it inherits from another
class, has public attributes or fields, special methods, accessors, static or async methods, a
parameter or result that cannot cross, or a method that changes an argument or prints). Use
`--keep Name` on `bridge` to keep one by hand.
In `port.go` a class is a Go type with a constructor and one method per method of the original:
```go
type Stack struct{ items []string } // the state an instance keeps
func NewStack(capacity int64) (*Stack, error) // an error is the original's raise
func (s *Stack) Push(item string) (int64, error) // a method, typed as a function is
```
The object lives in Go; the caller's object holds a handle to it, and releases it when it is
collected. `record` writes one scenario per line: a constructor and a sequence of calls with what
each answered, and `diff` says where a scenario first differs as `call N`. `bench` times a class by
whole scenarios, in a row named `class <Name>`. Methods take no `stdout` and no pointer
parameters.
What is not built for classes yet, per `docs/STATUS.md`: `fuzz` makes no class scenarios, and
`gate` does not check classes (on a unit with a class and no function it failed the `recording`
check with `no recorded case for <Class>`). When `gate` fails like that, show the user the result of
`diff` and say that `gate` cannot judge the class yet; do not call the unit done.
## 3. Prove it
```sh
go-anything build <module> # the C shared library, in build/
go-anything diff <module> # must be N/N
go-anything bench <module> # original vs Go, bridge included, with a verdict
go-anything fuzz <module> --seed 7 # fresh inputs the recording does not hold
```
`diff` replays every recorded case through the wrapper, called as the original's callers call it,
and exits 1 when any case differs. It groups the mismatches into distinct differences (fix the
largest group first) and names where each first differs (`at`): the return or throw, the error
class, the JSON path and character, an argument after the call, the printed output, or `call N` for
a class. `diff --redact` shows only shapes, lengths and hashes, no values, to hand a failing diff to
someone else; `diff --json` is the machine-readable form.
A mismatch is a behavior difference: fix the port, never the recording. An intended difference (the
bug fix that follows a passing `gate`, or a value Go cannot hold, such as a lone surrogate) needs
the user's yes first. Then add one line per case to `<module>/known-diffs.jsonl`:
`{"fn", "args", "actual", "reason"}`, with `fn`, `args` and `actual` copied from `diff --json`. The
case then passes only with exactly that result, and `gate` fails once it no longer differs: remove
the line then. For a Python port that keeps `int` as `int64`,
`{"fn", "when": "int-beyond-i64", "reason"}` covers every mismatch of that function whose original
result is an int beyond `int64`. A mismatch whose result fits still fails.
If `gate` says the recording is stale, the original changed: record again before you port further.
After you pull upstream changes, run `go-anything map <repo>`: every port it marks changed needs
`record`, then `diff`, and the new mismatches are what changed upstream. `go-anything map <repo> --check` exits 1 when a recording is outdated or cannot be trusted.
Numeric code (physics, statistics, graphics) rarely gives bit-identical floats once ported:
operation order, fused multiply-add and the math library differ. When the user accepts that, record
with `--float-tolerance 1e-9` (their number): floats then match within that share of the larger
value, and `diff` and `gate` use it. Integers, strings and the same value written differently (`3`
and `3.0`) still must match exactly. Never widen a tolerance to make a mismatch go away: a
difference beyond it is a bug in the port. Above `1e-6`, `record` refuses unless you also pass
`--allow-large-tolerance`.
`bench` times each function on both sides over the recorded arguments, crossing included, and says
whether to ship. A small function called once per item is slower through the bridge: every call
crosses as JSON, and on `demo/py-textkit` the port was about 15 times slower than the original per
call. Follow the verdict: port a bigger unit (the function together with its callers), keep the
slower functions in the source language, and do not ship a port that makes callers slower without
saying so. A batch is the remedy for a function called once per item:
- `go-anything bridge <repo> <unit> --batch function:param` (or `go-anything refresh <module> --batch
function:param`) gives the wrapper a `<Function>Batch` class: the items stay in Go, `run` maps them
on all cores and `rank` orders them; `gate`'s `batch` check requires it to answer what one call per
item answers.
- Items and other arguments: `param` names the argument that takes the items; the others are passed
once per `run`. `--batch` is not available for C, PHP, Swift, Java, Kotlin, C#, PowerShell and
Rust units yet.
`fuzz` runs fresh inputs from a new seed through both sides and reports where they differ: what the
recorded cases did not cover. It prints the seed, so a failure can be replayed with `--seed`;
`--cases` sets the cases per round, `--time` keeps running rounds, and `--keep` appends the
mismatching cases to `cases.jsonl` so the next `diff` and `gate` check them. `--generator` runs your
own command for the inputs. Exit status 1 means a fresh case differs: that is a finding to report
and fix in the port, not to ignore.
## 4. Ship it safely
```sh
go-anything shadow <module> # a drop-in that runs both sides
go-anything enable <module> # switch the unit on for every caller
go-anything disable <module> # take it out again
```
`shadow` writes a module with the original's names (Python: `shadow/<name>_shadow.py`, TS/JS:
`shadow/<name>.shadow.ts`). Import it where the app imported the original. With
`GO_ANYTHING_MODE=shadow` (the default) every call returns the original's result and the Go result
is compared and mismatches are reported; `new` runs Go only, `old` the original only. There is no
shadow module for PHP, Swift, Rust, C# or PowerShell: skip `shadow` for them and, once `diff` passes, load the
wrapper `bridge` wrote in place of the original.
`enable` switches a unit on in place instead: one marked block in each original source file loads
the built module and rebinds the ported functions, so no import changes. It builds and diffs first
and refuses while a recorded case differs; `--partial` switches on the functions whose cases all
match and `--only` the ones you name. It falls back to the original when the module does not load
(with `GO_ANYTHING_MODE=new` that is an error). `disable` removes the block and gives the files back
byte for byte. `GO_ANYTHING_UNIT_<NAME>=original` (the module name without `-go`, upper case) or
`GO_ANYTHING_MODE=old` runs the original for one run. An enabled unit is still recorded, diffed and
gated against the original. **Ask the user before enabling: it edits their source files.** Every
`enable`, `disable` and `gate` appends a line to `go/audit.jsonl`.
To hand the port to the original's users as a package instead, once `gate` passes:
```sh
go-anything package <module> --dry-run # list what it would write
go-anything package <module> # writes <module>/build/package/
```
A TypeScript/JavaScript port becomes an npm package (one package per platform holding that
platform's library, the original as the fallback when it is one plain JS file) and a Python port a
wheel importable under the original's module name. It writes files, builds the wheel for this
machine, replays the recorded cases through what it wrote, and writes a GitHub Actions workflow that
builds each other platform on a runner of its own: cgo needs that platform's C compiler, so nothing
is cross-compiled. It never publishes. `GO_ANYTHING_MODE=old` runs the original when the package
carries it. Packaging a whole app's front door is not covered yet.
## 5. Done means gate passes
```sh
go-anything gate <module>
```
`gate` prints one verdict per check and exits 1 when any fails; a failed check carries a `fix`: run
that first. It runs gofmt, go vet, staticcheck (when installed), go test, `go.sum`, the unsafe audit
(no `unsafe`, cgo, linkname, plugin or reflect pointer tricks), nothing unported (no stub is left),
size (the port at most three times the original's lines plus 50; over that, use the standard
library or the Go module `analyze` lists and fold repeated code, and if matching the original needs
more, tell the user instead of dropping behavior: only they can allow a unit more, with an ADR in
`go/DECISIONS.md` and a `[[size]]` entry in `go/obligations-decisions.toml`), the cheat guard `literals` (no recorded
answers in the port), `runtime` and `spawns` (no program started, no library loaded, nothing read
from the recording), the tests baseline (fewer tests, assertions or more skipped ones than at the
last passing gate fail), a recorded failing case for every error path of the original, no panic or
dropped error where the original returns an error, build, API (every export present), behavior
(every recorded case matches), the recording (stale, edited, missing `recorded-from.json`, smaller
than at the last passing gate), accepted diffs, and held-out inputs: fresh and perturbed inputs the
recording does not hold, run through the original and the port, with the seed printed so a failure
can be replayed (`--held-out-seed`). A missing `go.sum` and `govulncheck` findings only warn. Read
the verdict of each check; do not loosen one to get a pass.
**Never loosen a verdict to turn it green.** These make a pass weaker, and only the user decides to
use them, after reading what they cover: `gate --accept-known-diffs <count>`,
`gate --accept-smaller-recording`, `gate --held-out-cases 0` (turns the held-out check off),
`record --allow-dropped`, `--float-tolerance` (above `1e-6` also `--allow-large-tolerance`),
`--ignore-key-order`, `record --no-messages`, and `enable --force`. Do not write a `[[size]]`
decision, add lines to `known-diffs.jsonl`, delete `recorded-from.json` or a recorded case, or edit
`cases.jsonl` to get a pass. A loosened comparison is printed on the first line of the verdict, as
`comparison loosened: ...`: quote it in your report. A pass that lists a tolerance, accepted
differences or dropped inputs is a weaker pass: say so.
Then report to the user, and **wait for their go-ahead before the next unit**:
- what changed (files, functions, classes), and what stayed in the original,
- the output of `gate`, the `diff` counts and the `bench` numbers,
- behavior differences or risks left that the recording does not reach, and what is left in the
plan.
## After a unit
- `go-anything report <module>` writes `report/REPORT.md`, `report/card.svg` and `report/report.json`
for the pull request: cases matched, the speedup, whether the unit is on, the machine. It builds
first, refuses a stale or edited recording, and reads the speedup from the last `bench`: with no
`bench` result, or one older than the port's code, it says "not measured" and claims no speed.
- `go-anything map <repo>` shows every unit, its port module, cases, last diff and last switch, and
which recordings the original has changed past. `--write` keeps it in `go/PORT_MAP.md`.
- `go-anything log <repo>` prints `go/audit.jsonl`: every gate and every switch, newest last. The
file holds no user name, email address or absolute path, so it can be committed with the port.
- `go-anything clean <repo>` removes what port modules build (`build/`, the `node_modules` of a
TS/JS wrapper, scratch state in `.go-anything/`); `--dry-run` prints what would go. It keeps
gate's baseline and last verdict. `--go-cache` with `--force` also clears Go's build cache, which
every Go project on the machine shares: ask first.
- `go-anything selftest` checks the checking: it plants wrong ports and tampered recordings against
a tiny built-in original in a scratch folder, and requires `diff` or `gate` to refuse each one
and to pass a correct port. It is not part of a port; run it when you change the checks, not for
every unit. A bug it lists as a known gap is not a failure of the run.
## A whole app
`app record` and `app replay` check a whole program from the outside, for a rewrite of the app
rather than a port of one function.
- `go-anything app record <repo> -- python3 cli.py` runs a CLI on the `$ tool ...` examples in its
docs, `--inputs` and the semantic traps, twice each, and writes the cases to `go/app-cases/`.
- With `--http`, `go-anything app record <repo> -- python3 server.py` does the same for a server: it starts
the server with its port in `PORT` (or `{port}` in the command, or `--port`), sends the `curl`
lines of its docs, `--inputs` requests and the traps, and writes `go/app-cases/http/<case>.toml`
(the request, the status, the headers) and `<case>.body`. `--ready "GET /health"` waits for a
route to answer 2xx; `--arg` and `--fresh` are given to every start and saved.
- What differs between the two runs becomes a `[..]` wildcard, listed as noise: show it to the
user. `--normalize timestamps`, `uuids` or `key-order` says what changes on purpose (a time in a
body, keys in another order); record with it rather than accept the noise.
- With `--http`, `go-anything app replay <repo> -- ./new-server` starts the build once, sends every
recorded request in order and names each difference by status, header and body; it writes
`go/app-cases/replay-report.md` and exits 1 when a case differs. `--case` replays one case.
- Then move the entry point to Go and hand it one unit at a time.
`go-anything app front-door <repo>` scaffolds `go/app`, a Go program where every command (or, for a
server, every request) still runs the original; it builds it and replays: 100% passed at 100%
fallback. It never overwrites `go/app`: the code is yours from then on.
- After a unit passes `gate`, `go-anything app wire <repo> <unit>` with `--command <name>` (for a
server, `--route 'GET /users/{id}'`, `/path` for any method, `*` for the rest) writes
`go/app/units/<unit>/<unit>.go` once: fill it in (read the arguments or the request, call the port,
print or answer what the original does), then run the same `app wire <repo> <unit>` again. Replay
must stay at 100% while the fallback rate drops. `GO_ANYTHING_UNIT_<NAME>=original` sends a wired
unit back to the original; `GO_ANYTHING_FALLBACK_JOURNAL=<file>` makes the front door journal each
fallback as a JSON line.
- When replay passes with fallback rate 0, every unit passes `gate` and
`go-anything obligations <repo> --check` lists nothing, `go-anything app lift <repo>` makes `go/app`
pure Go: checked on a copy (no fallback, no kill switches, the port modules without their
bindings, gofmt, go vet and go test, nothing that starts the original), replayed with the
original's files moved away, then copied back. It refuses and lists the blockers otherwise; waiving
or attesting an obligation is the user's decision, never yours.
- Side effects (outbound HTTP, mail, a database) are not recorded yet: an app whose answers depend
on them is not checked by these cases.
### Rules for a whole app
1. Never declare the port finished, propose the switch-over or write a final report while
`go-anything obligations <repo> --check` lists a blocker or fails. The report gives the exact
count of blockers and the list of what a decision closed instead of a case: the items waived,
the families attested and the obligations bound by hand (the `obligations_check` tool returns
them as `waived`, `attested` and `closed_by_binding`).
2. Never run `go-anything obligations waive` or `obligations attest` on your own initiative, and
never write a binding on your own either: waiving an obligation, attesting a family and binding
cases to an obligation are the user's decisions, and the reason is theirs. Present each item to
the user; the user decides item by item.
3. Never delete or hand-edit `go/obligations-decisions.toml`, `go/obligations-fallbacks.jsonl` or the
ADRs that `waive` and `attest` wrote in `go/DECISIONS.md`. A binding is one `[[bind]]` table in
`go/obligations-bindings.toml` with three keys, all required: `obligation` (an id from the
ledger, bound once), `cases` (case references: `cli:<name>`, `http:<name>` or
`unit:<module>:<line>`, of cases that exist and are not skipped) and `reason` (why the cases
exercise the obligation). It is the user's call, written only on their yes and never to a case
that fails or does not reach the obligation.
4. Never change a recorded case to make a port match; changing one needs the user's approval.