# Migrate a Team from GitHub to Motor: Agent Checklist

This checklist moves a repository and its team from Git, GitHub, and GitHub Actions to Motor: Amp
for version control, Gauss for code hosting, and Piston for CI and deploys. When it's done, the
team works entirely on Motor and their agents follow the Motor workflow.

**If you're starting the migration:** open your coding agent in your Git repository and give it this
prompt:

> Move this project and its team from Git and GitHub to Motor. Install the Motor CLI
> (`curl -fsSL https://gauss.motor.dev/motor/cli/artifacts/install.sh | sh`). If this directory is
> a Git repo without a GitHub remote, let me know, then run `motor learn import` and follow that
> checklist instead; if it isn't a Git repo, ask me which project to move. Run
> `motor learn migrate` and read the entire checklist. Summarize what it will change and get my okay
> before starting. Then work through it from first step to last, stopping at every USER ACTION step
> to tell me what to do.

`motor learn migrate` prints this checklist. You can also read, copy, or download it at
https://www.motor.dev/docs/migrate.

Your agent handles most of the work. It pauses whenever a step needs you—for example, to approve the
plan, sign up for Motor, approve a sign-in, add a payment card, or enter a secret value. It also
asks for your okay before touching GitHub or production.

---

## 0. Rules for the agent

Follow these rules throughout the migration.

- **R1.** Run the steps in order. Don't skip a step, and don't start the next step until the current
  one is done.
- **R2.** Every step is labeled **[AGENT]**, **[USER ACTION]**, or **[AGENT + USER]**.
- **R3.** At a **[USER ACTION]** step, stop and send the user the text from the "Tell the user"
  block with all variables filled in. Wait until the user confirms they've finished, then run the
  step's **Verify** check.
- **R4.** After every step, run its **Verify** check. If it fails, follow the **If not**
  instructions; if there aren't any, stop and tell the user.
- **R5.** Pass `--json` to `amp` and `motor` commands whenever you need to parse their output, and
  always check the exit code.
- **R6.** Never ask for, read, write, print, or keep a secret value. Never put a secret value in a
  command argument, file, `env` value, or hook input.
- **R7.** Don't modify, delete, or archive anything on GitHub unless a step explicitly tells you to.
- **R8.** Replace every `<VARIABLE>` with its value from step 1.4 or from the command output named
  in the step (for example, `<MERGE_ID>` is `.id` from `motor gauss merge create --json`). Never run
  a command that still has a placeholder in it.
- **R9.** If a command fails twice, stop and tell the user the command, the error, and the
  `request_id` if one was returned.
- **R10.** Log every finding, loss, and decision in the migration report (`<WORK_DIR>/report.md`)
  and hand it to the user at the end (step 12.3).
- **R11.** Don't deploy, publish, or run a production task unless a step tells you to.
- **R12.** As soon as a check passes, move straight to the next step. Don't add extra wait times
  that aren't in this checklist.

### Warnings, cautions, and notes

- **WARNING** flags a risk of data loss or a change to production.
- **CAUTION** flags a risk of a failed migration or misconfiguration.
- **NOTE** adds helpful context.

### The LAND procedure

Several steps ask you to "land a change." Follow steps L1 through L7 whenever you do.

- **L1.** From the repository root, create a workspace for the task. `<TASK>` should be a short name
  using lowercase letters, digits, and hyphens.

  ```sh
  cd <REPO_DIR>
  amp workspace add workspaces/<TASK>
  cd workspaces/<TASK>
  ```

- **L2.** Set your identity in the workspace using your real agent name and model ID. Don't guess
  the model ID—if you don't know it, ask the user.

  ```sh
  amp workspace identity --agent <AGENT_NAME> --model <MODEL_ID> --for "<USER_NAME> <<USER_EMAIL>>"
  ```

- **L3.** Make your edits and record them with a message in "VERB NOUN PHRASE" form.

  ```sh
  amp record -m "<MESSAGE>"
  ```

- **L4.** Pull the latest main channel and run the repository's checks, if any exist.

  ```sh
  amp pull origin --from <MAIN>
  motor piston run . <CHECK_TARGET> --team <TEAM>      # run for each check target
  ```

- **L5.** Push your workspace channel, create a merge, and wait for it to finish. `<MERGE_ID>` is
  `.id` from the `merge create` output.

  ```sh
  amp push origin --to <TASK>
  motor gauss merge create <TEAM>/<REPO> --source <TASK> --target <MAIN> --title "<MESSAGE>" --json
  motor gauss merge wait <TEAM>/<REPO> <MERGE_ID>
  ```

- **L6.** If `merge wait` exits non-zero, inspect the merge:

  ```sh
  motor gauss merge show <TEAM>/<REPO> <MERGE_ID> --json      # check submission.rejection and generation
  motor gauss merge checks <TEAM>/<REPO> <MERGE_ID> --json
  motor gauss invocation show <TEAM>/<REPO> <INVOCATION_ID> --json
  motor piston logs <RUN_ID> --team <TEAM>
  ```

  Fix the issue:

  - **Failed check:** fix the code, record the change, and push (`amp push origin --to <TASK>`).
  - **Conflict:** run `amp pull origin --from <MAIN>` in the workspace, resolve the conflict, record
    the resolution, and push.
  - **Infrastructure failure:** diagnose the cause; no push is needed.

  Then resubmit the merge and wait again:

  ```sh
  motor gauss merge refresh <TEAM>/<REPO> <MERGE_ID> --expected-generation <N>
  motor gauss merge wait <TEAM>/<REPO> <MERGE_ID>
  ```

  Pushing alone doesn't resubmit a rejected merge.

- **L7.** Once the merge lands, clean up:

  ```sh
  cd <REPO_DIR>
  amp pull origin --from <MAIN>
  amp workspace remove workspaces/<TASK>
  amp channel delete <TASK> --remote origin
  ```

---

## 1. Preparation

### 1.0 [AGENT + USER] Get approval to start

1. Walk the user through what this migration will do:
   - Read the GitHub repository, its workflows, and the names of its secrets (never secret values).
   - Create a Motor team, invite teammates, and create a Gauss repository.
   - Ask the team to stop pushing to GitHub and disable the GitHub Actions workflows that are moving.
   - Import the Git history and move CI and deploys to Piston.
   - Update the repository's agent instructions to use Motor.
   - At the end, ask the user to revoke replaced GitHub credentials and archive the GitHub repo.
2. Let the user know you'll ask for their okay again before touching GitHub or production.
3. If the user already approved after hearing a summary like this, move on without asking again.
   Otherwise ask: "Ready for me to start the migration?"
4. Record their approval in the report in step 1.4.

**Verify:** the user approved starting the migration.

**If not:** stop.

### 1.1 [AGENT] Install Amp and the Motor CLI

1. Check whether both CLIs are installed: `amp --version` and `motor version`.
2. Install whichever one is missing:

   ```sh
   curl -fsSL https://gauss.motor.dev/motor/amp/artifacts/install.sh | sh
   curl -fsSL https://gauss.motor.dev/motor/cli/artifacts/install.sh | sh
   ```

**Verify:** `amp --version` prints `amp YYYY_MM_NNNN` (for example, `amp 2026_11_0001`).

**CAUTION:** another tool is also named `amp` (Sourcegraph's coding agent). If `amp --version`
prints anything else, a different `amp` is earlier on `PATH`. Tell the user and don't continue until
Motor's `amp` comes first on `PATH`.

### 1.2 [AGENT] Read the guides

Run these commands and read their full output:

```sh
amp learn
motor learn
motor learn gauss
motor learn piston
```

**NOTE:** this checklist (`motor learn migrate`) gives the step-by-step sequence; the guides cover
the full command syntax. If they ever disagree on syntax, follow the guide.

### 1.3 [AGENT] Confirm you can read the GitHub repository

1. Run `git ls-remote <GH_URL> HEAD`.
2. If `gh` is installed, run `gh auth status`.

**Verify:** `git ls-remote` prints a line with a commit hash.

**If not:** follow the USER ACTION below.

> **USER ACTION — give GitHub access**
>
> Tell the user: "I can't read `<GH_URL>`. Please give this machine read access by running
> `gh auth login` followed by `gh auth setup-git`, or by adding an SSH key with read access to the
> repo. Let me know when that's set."

**NOTE:** `gh` is optional. Without it, steps 2.6, 2.9, 4.2, and 11.2 will need a few extra USER
ACTIONs.

### 1.4 [AGENT + USER] Set the variables

1. Gather these values yourself:
   - `<GH_URL>`: the clone URL of the GitHub repository.
   - `<GH_REPO>`: the GitHub `owner/name`.
   - `<MAIN>`: the default branch, from `git ls-remote --symref <GH_URL> HEAD`.
2. Ask the user for the remaining values, suggesting a sensible default for each:

| Variable | Meaning | Rule or default |
| --- | --- | --- |
| `<TEAM>` | Motor team handle | 3–39 characters: lowercase letters, digits, and single underscores between words, starting with a letter. Can't be the user's personal handle (users and teams share one namespace, and personal teams can't add members). |
| `<REPO>` | Gauss repository name | 1–100 characters: lowercase letters, digits, and single underscores between words, starting with a letter (for example, `my-app` becomes `my_app`). |
| `<REPO_DIR>` | New local directory for the Amp repo | Absolute path, defaulting to `../<REPO>_motor` next to the Git checkout. Must not already exist. |
| `<WORK_DIR>` | Scratch directory for migration files, outside the repo | Absolute path, defaulting to `../<REPO>_migration`. |
| `<USER_NAME>`, `<USER_EMAIL>` | Person running the migration | — |
| `<ADMINS>` | Emails for team admins | At least two people. Admins manage secrets and profiles. |
| `<MEMBERS>` | Emails for all other teammates | — |

3. Run `mkdir -p <WORK_DIR>`.
4. Record every variable at the top of `<WORK_DIR>/report.md`.

**Verify:** every variable in the table is filled in and follows its rule, and `<REPO_DIR>` and
`<WORK_DIR>` both start with `/`.

---

## 2. Inventory (read-only)

Read only in this section—don't change anything on GitHub.

### 2.1 [AGENT] Mirror the GitHub repository

```sh
git clone --mirror <GH_URL> <WORK_DIR>/inventory.git
```

**Verify:** `git -C <WORK_DIR>/inventory.git branch --list` lists every branch from GitHub.

**NOTE:** a mirror also pulls GitHub's `refs/pull/*` refs, while the import (step 5.1) only reads
branches and tags. Use `--branches --tags`, not `--all`, in the commands below.

### 2.2 [AGENT] Check for submodules

```sh
git -C <WORK_DIR>/inventory.git log --branches --tags --raw --ignore-submodules=none --format= | grep -c ' 160000 ' || true
```

**Verify:** the output is `0`.

**If not:** follow the USER ACTION below.

> **USER ACTION — submodules in history (BLOCKER)**
>
> Tell the user: "This repo's history includes a submodule. Amp refuses a full import if any commit
> ever contained a submodule, even if it was removed later. Pick one:
> (A) Rewrite the history without the submodule (for example, with `git filter-repo`) and import the
> rewritten copy.
> (B) Import a snapshot of the current files without history, leaving GitHub as the archive of the
> old history.
> (C) Stop the migration."

Record the user's choice in the report. You'll execute it in step 5.1, after the freeze, so the
import captures the final commits.

### 2.3 [AGENT] Check for Git LFS

```sh
git -C <WORK_DIR>/inventory.git log --branches --tags -p -- '*.gitattributes' | grep -c 'filter=lfs' || true
```

If the output is greater than `0`, the repository uses Git LFS:

1. Note in the report that the repo uses Git LFS.
2. Run `git lfs version`. If `git lfs` isn't installed, install it or ask the user to.

**NOTE:** the import brings each LFS file across with its real contents from a local mirror that has
the LFS objects. Step 5.1 clones that copy and fetches the objects from GitHub after the freeze.

**Verify:** the output is `0`, or the report notes Git LFS and `git lfs version` succeeds.

### 2.4 [AGENT] Record history size

```sh
du -sh <WORK_DIR>/inventory.git
git -C <WORK_DIR>/inventory.git rev-list --branches --tags --count
```

Record both numbers in the report.

### 2.5 [AGENT] Inventory workflows

1. Read every file in `.github/workflows/` on `<MAIN>`, plus any local actions in
   `.github/actions/`.
2. Add a row to a table in the report for each job: file, job name, triggers (`on:`), `paths` and
   `paths-ignore` filters, `runs-on`, `services:`, matrix, `secrets.*` names, `vars.*` names,
   `environment:`, and `uses:` actions.
3. Classify each job (if a job has multiple triggers, list every class that applies):

| Class | Trigger | Equivalent on Motor |
| --- | --- | --- |
| CHECK | `pull_request`, `merge_group`, or `push` to non-`<MAIN>` branches | A Piston task, a `merge.candidate_updated` hook, and a required check |
| POST-LAND | `push` to `<MAIN>` | A `channel.updated` hook |
| RELEASE | tag `push`, `release` | A `tag.created` hook |
| MANUAL | `workflow_dispatch` | A hook triggered manually with `motor gauss hook invoke` (see step 8.4) |
| SCHEDULED | `schedule` | A `schedule` hook (step 8.4), if the user chooses to move it in step 2.10 |
| UNSUPPORTED | `runs-on` macOS, or a self-hosted runner | **No equivalent.** See step 2.10. |

### 2.6 [AGENT] Inventory secrets and variables

Collect **names** only—never values.

```sh
gh secret list --repo <GH_REPO>
gh variable list --repo <GH_REPO>
gh api repos/<GH_REPO>/environments --jq '.environments[].name'
```

For each environment, list its secret and variable names too
(`gh secret list --env <ENV> --repo <GH_REPO>`).

Cross-check those lists against `secrets.` and `vars.` in the workflow files. Anything referenced in
a workflow but missing from the lists is usually an organization-level secret or variable—include it.

If `gh` isn't available, pull the names straight from `secrets.` and `vars.` in the workflow files.

Add a table to the report with each name, its environment (if any), and the jobs that use it.

### 2.7 [AGENT] Find tools that depend on Git

Amp repositories don't have a `.git` directory, so anything calling `git` will fail.

1. In a checkout of `<MAIN>`, search for:
   - `git describe`, `git rev-parse`, `git log`, `git diff`, `git status`, `git ls-files`
   - `husky`, `lint-staged`, `pre-commit`, `simple-git-hooks`
   - `semantic-release`, `changesets`, `setuptools_scm`, `standard-version`
   - `--changedSince`, `--onlyChanged`, `nx affected`, `turbo` filters with `[HEAD`
   - `danger`
2. Check `package.json`, `Makefile`, `*.mk`, `justfile`, `Taskfile*`, script directories, build
   configs, and `.github/`.
3. For each match, log the file, line, and proposed replacement in the report (using
   `amp status --json`, `amp log --json`, or the Piston run's source state—see step 8.4).

### 2.8 [AGENT] Find agent instruction files

Search the repo for `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.cursorrules`, `.cursor/rules/*`,
`.github/copilot-instructions.md`, `CONTRIBUTING.md`, and any agent command or skill files (such as
`.claude/commands/*`).

Inside each file, locate anything referencing Git or GitHub: `git `, `gh `, `pull request`, `PR`,
`branch`, `commit`, `rebase`, `squash`, `GitHub Actions`, `.github/`, `CI`, and conventional-commit
rules.

Log each file and line in the report so you can update them in section 10.

### 2.9 [AGENT] Inventory integrations

```sh
gh api repos/<GH_REPO>/hooks --jq '.[].config.url'
```

Also note any external services mentioned in workflows or the README, like Vercel, Netlify, Codecov,
Sentry, Renovate, Dependabot (`.github/dependabot.yml`), Linear, or Jira.

Record every integration in the report.

### 2.10 [USER ACTION] Review the inventory and confirm decisions

> **USER ACTION — approve the inventory**
>
> Tell the user: "The inventory is ready in `<WORK_DIR>/report.md`." Then walk them through:
>
> 1. Any blockers from 2.2 and 2.3 and how they'll be handled.
> 2. Each SCHEDULED job and its cron schedule. Explain that it can become a `schedule` hook on
>    `<MAIN>` (Gauss uses UTC like GitHub; schedules must be at least 5 minutes apart, and Sunday is
>    `0`, not `7`). For each one, ask whether to: (A) move it to a `schedule` hook, (B) keep it on
>    GitHub Actions, or (C) turn it off.
> 3. Each UNSUPPORTED job: (A) keep it on GitHub Actions, or (B) turn it off.
> 4. Each integration: (A) replace it with a Motor hook or webhook, (B) keep it on GitHub, or (C)
>    remove it.
> 5. Issues, Projects, Discussions, and the Wiki (Motor doesn't include them): (A) keep them on
>    GitHub, or (B) move them to another tool.
> 6. Ask: "Are you good with moving ahead with the changes in the next sections?"

**CAUTION:** after the freeze (section 4), GitHub stops receiving new code, and Motor doesn't mirror
changes back. Any job or integration left on GitHub sees only the frozen code.

- Before keeping any job or integration on GitHub, check whether it reads the repository's code
  (building, testing, scanning, or deploying it).
- If it doesn't touch the code (for example, it only pings an external service), keeping it is fine.
- If it does use the code, warn the user: "`<JOB>` will only ever see the frozen code from before
  the migration. It won't test or deploy anything new that lands on Motor." Only keep it if the user
  explicitly signs off on that exception; otherwise pick another option.
- Log every kept item in the report with `uses code: yes` or `uses code: no`, and record the user's
  exception approval for every `yes`.

**Verify:** the report has a decision for every item, every kept item that uses the code has an
explicit exception sign-off, and the user approved moving ahead.

---

## 3. Motor account and team

### 3.1 [USER ACTION] Sign up for Motor

> **USER ACTION — sign up**
>
> Tell the user: "Sign up at https://www.motor.dev: sign in with Google, add a passkey, pick your
> personal handle, and add a payment card for your personal team. Let me know when you're done (or
> if you already have an account)."

### 3.2 [AGENT + USER] Sign in on this machine

1. Run `motor auth status --json`.
2. If there's already an active credential, move on to step 3.3.
3. Otherwise, tell the user: "I'm running `motor auth` now—please approve the sign-in in your
   browser." Then run `motor auth`. On a headless machine, run `motor auth --device` and give the
   user the code.

**Verify:** `motor auth status --json` shows an active credential for `<USER_EMAIL>`, along with a
`gauss` credential.

**NOTE:** `motor auth` also sets up a device credential for Amp to talk to Gauss, so Amp doesn't
need a separate token.

### 3.3 [AGENT] Check for the team

Run `motor teams list --json`.

- If `<TEAM>` is listed, `personal` is `false`, and your role is `admin`, skip ahead to step 3.5.
- If `<TEAM>` is listed and `personal` is `true`, stop and explain that personal teams can't add
  other members. Go back to step 1.4 and pick a different `<TEAM>`.
- If `<TEAM>` is listed and your role isn't `admin`, stop and explain that a `<TEAM>` admin needs
  to run the migration (or promote the user to admin).
- If `<TEAM>` isn't listed, continue to step 3.4.

### 3.4 [USER ACTION] Create the team

> **USER ACTION — create the team**
>
> Tell the user: "Create the team in the console at https://www.motor.dev/console/teams/new using
> the handle `<TEAM>`, and add a payment card (Motor creates the team once the card is verified).
> Let me know when it's ready."

**Verify:** `motor teams show <TEAM> --json` succeeds and reports your role as `admin`.

### 3.5 [AGENT] Invite the team

1. Run `motor members list --team <TEAM> --json`. Skip `<USER_EMAIL>` and anyone who's already a
   member.
2. For each remaining email in `<ADMINS>`:

   ```sh
   motor invites create --team <TEAM> --email <EMAIL> --role admin
   ```

3. For each remaining email in `<MEMBERS>`:

   ```sh
   motor invites create --team <TEAM> --email <EMAIL> --role member
   ```

**Verify:** `motor invites list --team <TEAM> --json` shows an open invite for everyone you invited.

**NOTE:** invites expire after 7 days. Sending a new invite to the same email replaces the previous
one.

### 3.6 [USER ACTION] Have the team accept their invites

> **USER ACTION — team onboarding**
>
> Tell the user: "Everyone on the team should have an invite email from Motor. Send them Appendix A
> of this checklist (https://www.motor.dev/docs/migrate#appendix_a_setup_for_each_team_member) so
> they can accept the invite and set up each computer they use. They can do that in parallel while
> I keep going." Also hand the user the `<TEAM>`, `<REPO>`, and `<MAIN>` values to include.

Don't wait for everyone to accept—move right on to section 4. You'll check team membership in step
12.1.

---

## 4. Freeze GitHub

### 4.1 [USER ACTION] Pause pushes to GitHub

**WARNING:** the import in step 5.1 is a one-time snapshot of GitHub. Commits pushed to GitHub
after the import won't make it to Motor.

> **USER ACTION — freeze GitHub**
>
> Tell the user: "Ask the team to push any branches they want to keep, then stop pushing to
> `<GH_REPO>`. Every branch on `<GH_REPO>` comes across as an Amp channel, though fork PRs, PR
> descriptions, and review comments don't transfer. Let me know once everyone has paused."

### 4.2 [AGENT + USER] Disable GitHub Actions workflows

**WARNING:** leaving GitHub Actions enabled risks having both GitHub and Motor deploy at the same
time.

1. List the workflows staying on GitHub—only the SCHEDULED and UNSUPPORTED jobs the user chose to
   keep on GitHub Actions in step 2.10.
2. Ask the user: "I'm going to disable every workflow on `<GH_REPO>` except: `<LIST>`. Good to go?"
3. Once approved, disable all the other workflows:

   ```sh
   gh workflow list --repo <GH_REPO>
   gh workflow disable "<WORKFLOW_NAME>" --repo <GH_REPO>
   ```

4. If `gh` isn't available, ask the user to disable those workflows in the repo's GitHub settings.

**Verify:** `gh workflow list --repo <GH_REPO> --all` shows every workflow not on the keep list as
`disabled_manually`.

---

## 5. Import the history

### 5.1 [AGENT] Run the import

**CAUTION:** imports only work into an empty repository and can't resume after an interruption. If
an import is interrupted, delete `<REPO_DIR>` and start this step over. If it fails with
`import_lfs_missing` or `import_lfs_bad`, nothing was imported—see **If not** below.

1. Refresh your local mirror so it has GitHub's final state (step 6.5 uses it):

   ```sh
   git -C <WORK_DIR>/inventory.git remote update --prune
   ```

2. Pick the import source. Normally `<SOURCE>` is `<GH_URL>`, which brings across every branch on
   GitHub. If the repo uses Git LFS (step 2.3) or needs a history rewrite (step 2.2), clone a
   separate working mirror, fetch its LFS objects, and modify that copy instead of touching
   `inventory.git`:

   ```sh
   git clone --mirror <GH_URL> <WORK_DIR>/source.git
   git -C <WORK_DIR>/source.git lfs fetch --all          # Git LFS only
   ```

   If you're rewriting history, run the user-approved command in `<WORK_DIR>/source.git`, then set
   `<SOURCE>` to `<WORK_DIR>/source.git`. If the user chose option (B) in step 2.2, confirm with
   them how they want the snapshot created.

3. Run the import. Initialize Amp with `<MAIN>` so history lands on the right default channel:

   ```sh
   mkdir <REPO_DIR>
   cd <REPO_DIR>
   amp init --channel <MAIN>
   amp import git --verify <SOURCE> --json > <WORK_DIR>/import.json
   ```

Keep `import.json` in `<WORK_DIR>`, not `<REPO_DIR>`, so Amp doesn't track it.

**Verify:**

- The command exits `0`.
- `jq '.commits, .changes' <WORK_DIR>/import.json` prints two numbers greater than `0`.
- `jq '.channels | keys' <WORK_DIR>/import.json` includes every branch from step 2.1.
- `amp status --json` shows you're on channel `<MAIN>`.
- If the repo uses Git LFS, `jq '.lfs.files' <WORK_DIR>/import.json` is greater than `0`.

**If not:** if the error code is `import_lfs_missing`, some LFS objects are missing from
`<WORK_DIR>/source.git`. Run `git -C <WORK_DIR>/source.git lfs fetch --all` again and retry the
import in the same `<REPO_DIR>` (the failed run didn't import anything). If objects are still
missing—for instance, because nobody ever uploaded them to GitHub—tell the user which files are
affected and offer two options: re-run with `--lfs=pointers` (which keeps those files as small
pointer files and records them in `.lost` and `.lfs.pointers`), or stop. Log their choice in the
report. If the error code is `import_lfs_bad`, an LFS object doesn't match its pointer or uses an
unsupported Git LFS extension: report the error to the user and stop.

### 5.2 [AGENT] Log what didn't transfer

1. Inspect `.lost` and `.tags` in `<WORK_DIR>/import.json`.
2. Record anything that couldn't be imported in the report—for example, commit or tag signatures,
   empty commits, or tags that don't point to a commit.
3. Share that summary with the user as an FYI, then keep moving.

---

## 6. Create the Gauss repository

### 6.1 [AGENT] Create the repo and grant team access

```sh
motor gauss repo create --team <TEAM> --name <REPO> --main-channel <MAIN> --json
motor gauss repo access set <TEAM>/<REPO> --team-scopes read,write
```

**CAUTION:** new repositories don't grant team access automatically. Without the second command,
non-admin teammates will get a 404.

**Verify:** `motor gauss repo access show <TEAM>/<REPO> --json` shows team scopes `read` and
`write`.

### 6.2 [AGENT] Connect the local repo and initialize agent instructions

```sh
cd <REPO_DIR>
amp remote add origin https://gauss.motor.dev/<TEAM>/<REPO> --channel <MAIN>
motor init
```

`motor init` inserts a Motor section between `<!-- motor:start -->` and `<!-- motor:end -->` in
`AGENTS.md` (creating the file if needed), adds `/workspaces/` to `.ampignore`, and records those
edits on `<MAIN>`. It works offline without signing in.

**Verify:**

- `grep -c 'motor:start' AGENTS.md` prints `1`.
- `grep -c '<TEAM>/<REPO>' AGENTS.md` prints at least `1`.
- `amp status --json` shows a clean workspace.

### 6.3 [AGENT] Land the history

The main channel only accepts changes through a merge. Since no required checks exist yet, this
initial merge lands right away.

```sh
amp push origin --channel <MAIN> --to import --tags --json > <WORK_DIR>/push_main.json
motor gauss merge create <TEAM>/<REPO> --source import --target <MAIN> --title "Import the Git history" --json
motor gauss merge wait <TEAM>/<REPO> <MERGE_ID>
amp channel delete import --remote origin
```

**Verify:** `merge wait` exits `0`.

### 6.4 [AGENT] Push the remaining channels

Save each push's JSON output in `<WORK_DIR>`:

```sh
for ch in $(amp channel list --json | jq -r '.channels[].name' | grep -vx '<MAIN>'); do
  amp push origin --channel "$ch" --to "$ch" --tags --json > "<WORK_DIR>/push_$(echo "$ch" | tr / _).json"
done
```

**Verify:** neither `<WORK_DIR>/push_main.json` nor any other push output contains `tag_errors`,
and every tag in `import.json`'s `.tags` appears in `.tags` of one of those outputs.

**If not:** log any missing tags in the report and let the user know.

### 6.5 [AGENT] Verify the import

1. Clone the new Gauss repo into a temporary directory:

   ```sh
   amp clone https://gauss.motor.dev/<TEAM>/<REPO> <WORK_DIR>/check_clone --channel <MAIN>
   ```

2. Pick `<MAIN>` and two other branches. For each branch, let `<BRANCH>` be its name and `<NAME>`
   be its name with `/` replaced by `_`. Grab the Git commit hash:

   ```sh
   git -C <WORK_DIR>/inventory.git rev-parse <BRANCH>      # this is <GIT_SHA>
   ```

   If you imported from `<WORK_DIR>/source.git` in step 5.1, use `source.git` instead of
   `inventory.git` here and in step 3.

3. For each branch, diff the imported files against Git:

   ```sh
   cd <REPO_DIR>
   amp import map <GIT_SHA> --json          # read .state: this is <STATE>
   amp export state:<STATE> <WORK_DIR>/export_<NAME>
   mkdir <WORK_DIR>/git_<NAME>
   git -C <WORK_DIR>/inventory.git archive <GIT_SHA> | tar -x -C <WORK_DIR>/git_<NAME>
   ```

   If the repo uses Git LFS (step 2.3), hydrate the LFS files in `git_<NAME>` from `source.git`.
   First, write out any OIDs the user accepted as pointers in step 5.1 (this file stays empty if
   there were none):

   ```sh
   jq -r '.lfs.pointers[]?.oid' <WORK_DIR>/import.json > <WORK_DIR>/lfs_accepted
   ```

   Then, for each branch:

   ```sh
   tree=<WORK_DIR>/git_<NAME>
   store=<WORK_DIR>/source.git/lfs/objects
   accepted=<WORK_DIR>/lfs_accepted
   find "$tree" -type f -size -1024c | sort | while IFS= read -r f; do
     head -1 "$f" | grep -qx 'version https://git-lfs.github.com/spec/v1' || continue
     oid=$(sed -n 's/^oid sha256://p' "$f"); size=$(sed -n 's/^size //p' "$f")
     obj="$store/$(echo "$oid" | cut -c1-2)/$(echo "$oid" | cut -c3-4)/$oid"
     if [ ! -f "$obj" ]; then
       if grep -qx "$oid" "$accepted"; then echo "kept pointer: $f"; continue; fi
       echo "missing LFS object: $f"; exit 1
     fi
     sum=$( (sha256sum "$obj" 2>/dev/null || shasum -a 256 "$obj") | cut -d' ' -f1)
     if [ "$sum" != "$oid" ] || [ "$(wc -c < "$obj" | tr -d ' ')" != "$size" ]; then
       echo "bad LFS object: $f"; exit 1
     fi
     cp "$obj" "$f"
   done
   ```

   Every LFS file now holds the verified contents GitHub served, while any accepted pointers stay as
   pointers to match the import. Now diff the two trees:

   ```sh
   diff -r <WORK_DIR>/git_<NAME> <WORK_DIR>/export_<NAME>
   ```

4. Diff what's on Gauss against Git for `<MAIN>` (using `<NAME>` from step 2):

   ```sh
   amp -C <WORK_DIR>/check_clone export channel:<MAIN> <WORK_DIR>/export_gauss
   diff -r <WORK_DIR>/git_<NAME> <WORK_DIR>/export_gauss
   ```

**Verify:**

- The clone succeeds.
- If the repo uses Git LFS, the hydration loop in step 3 exits `0` for every branch.
- Every `diff` in step 3 comes back empty.
- The `diff` in step 4 shows differences only in `AGENTS.md` and `.ampignore`.

**NOTE:** `git archive` skips files marked `export-ignore` in `.gitattributes`, so a difference in
those files is expected.

---

## 7. Move CI to Piston

### 7.1 [AGENT] Write the check tasks

1. Create a workspace for this work (LAND procedure, steps L1 and L2) with the task name
   `piston-checks`.
2. Add `piston.star` at the repository root with one task per CHECK job from step 2.5, using
   Appendix B to translate each piece of the workflow.
3. Update any tools from step 2.7 that those checks rely on so they no longer require Git.

Example `piston.star` for a Node project with Postgres:

```python
load("@piston//debian.star", "apt")
load("@piston//postgres.star", "postgres_configure", "postgres_start")

NODE = image("node:22-bookworm")

def node_pg(v):
    return layer(image("node:%s-bookworm" % v), name = "node%s_pg" % v, steps = [
        apt(["postgresql"]),
        postgres_configure(trust_local = True),
    ])

lint = task(
    name = "lint",
    image = NODE,
    cpu = 4,
    caches = {"/root/.npm": "npm"},
    steps = [sh("npm ci"), sh("npm run lint")],
    timeout = "15m",
)

tests = [
    task(
        name = "test_node%s" % v,
        image = node_pg(v),
        cpu = 8,
        caches = {"/root/.npm": "npm_%s" % v},
        env = {"DATABASE_URL": "postgres://postgres@127.0.0.1:5432/postgres"},
        steps = [
            postgres_start(),
            sh("npm ci"),
            sh("npm test -- --reporters=default --reporters=jest-junit", report = junit("junit.xml")),
        ],
    )
    for v in ["22"]
]
```

**NOTE:** a task only receives the secrets it explicitly declares. Checks can only use
**repository** secrets (see section 8)—never give a check a production credential.

### 7.2 [AGENT] Get each check passing

For each check task:

```sh
motor piston check . --json
motor piston plan . <TARGET> --json
motor piston run . <TARGET> --team <TEAM>
```

If a task fails, inspect `motor piston logs <RUN_ID> --team <TEAM>`, fix the issue, and re-run.

If a check needs a secret that isn't configured yet, run step 8.3 for that secret and then come
back here.

**Verify:** every check task passes against the current `<MAIN>`.

**If not:** if a task still fails after three tries, stop and share the task name, error, and what
you've tried with the user.

### 7.3 [AGENT] Declare the check hooks

Create `.gauss/hooks.star` with one hook per check task:

```python
hook(
    name = "lint",
    check = "lint",
    events = ["merge.candidate_updated"],
    channels = ["<MAIN>"],
    action = piston(config = "piston.star", targets = ["lint"]),
)
```

If the original `pull_request` trigger used `paths` or `paths-ignore`, carry those patterns over to
`paths` or `paths_ignore` (see Appendix B). When a merge doesn't touch any matching path, Gauss
marks the required check `skipped`, which won't block the merge.

Validate the file:

```sh
motor gauss hook validate <TEAM>/<REPO> --dir .gauss --event merge.candidate_updated --event-channel <MAIN>
```

For each hook with `paths` or `paths_ignore`, validate it with one path that should match and one
that shouldn't:

```sh
motor gauss hook validate <TEAM>/<REPO> --dir .gauss --event merge.candidate_updated --event-channel <MAIN> --event-path <PATH>
```

**Verify:** `hook validate` exits `0` with no errors and matches every check hook. Path-filtered
hooks match the paths they should and skip the ones they shouldn't.

### 7.4 [AGENT] Land the checks

1. Land the change (LAND procedure, steps L3–L7) with the message `"Run the checks on Piston"`.
2. List the merge's checks: `motor gauss merge checks <TEAM>/<REPO> <MERGE_ID> --json`.
3. Because no checks are required yet, the merge may land before they finish. Wait for every check
   invocation to complete:

   ```sh
   motor gauss invocation wait <TEAM>/<REPO> <INVOCATION_ID>
   ```

**Verify:** the merge lands and every `invocation wait` exits `0`.

### 7.5 [AGENT] Require the checks on `<MAIN>`

1. Fetch the current policy revision (`revision` is `0` if no policy exists yet):

   ```sh
   motor gauss policy show <TEAM>/<REPO> <MAIN> --json
   ```

2. Set the policy, passing `--require` once for **each** check (using each hook's `check` name).
   Every `policy set` call replaces the entire list:

   ```sh
   motor gauss policy set <TEAM>/<REPO> <MAIN> --revision <REV> --require lint --require test_node22 --forbid-direct-pushes
   ```

**Verify:** `motor gauss policy show <TEAM>/<REPO> <MAIN> --json` lists every required check and
forbids direct pushes.

### 7.6 [AGENT] Confirm a failing check blocks a merge

1. Create a workspace named `check-the-queue`.
2. Add a test that always fails, record it, push it, and open a merge (LAND procedure, steps L3–L5).
3. Confirm that `merge wait` exits non-zero and the merge status is `rejected`.
4. Close the merge and clean up the workspace and channel:

   ```sh
   motor gauss merge close <TEAM>/<REPO> <MERGE_ID> --reason "Test of the merge queue"
   cd <REPO_DIR>
   amp workspace remove workspaces/check-the-queue --delete-channel
   amp channel delete check-the-queue --remote origin
   ```

**Verify:** the merge was rejected and `<MAIN>` doesn't contain the failing test.

---

## 8. Secrets, deploys, and releases

Only run the parts of this section that apply to this repo:

| What steps 2.5 and 2.6 found | Steps to run |
| --- | --- |
| POST-LAND, RELEASE, or MANUAL jobs, or SCHEDULED jobs moving to Motor (with or without secrets) | 8.1 through 8.6 |
| Secrets only, none of those jobs | 8.1 and 8.3. Skip 8.2, 8.4, 8.5, and 8.6. |
| Neither secrets nor those jobs | None—jump straight to section 9. |

In this section, "deploy hook" refers to any hook for a POST-LAND, RELEASE, or MANUAL job, or a
SCHEDULED job the user chose to move to a `schedule` hook in step 2.10.

### 8.1 [AGENT] Categorize secrets

Assign a destination to every secret from step 2.6 and log it in the report:

| Used by | Destination | Who can read it |
| --- | --- | --- |
| A CHECK job (safe for tests) | Repository secret | Any writer running `motor piston run`, plus any hook run for a task without a profile (including checks) |
| A deploy, release, or publish job | Profile secret (for example, profile `production`) | Only tasks using that profile, triggered by a hook whose `piston(profile = ...)` names it, for an event and channel or tag allowed by the profile's rules |
| AWS access keys for deploys | **Don't migrate.** Use a profile's AWS IAM role instead (step 8.2). | — |
| Multiple repositories in the team | A repository or profile secret in each repo that needs it | Same as above. Hook runs never receive team secrets (`motor piston secrets`). |

**WARNING:** anyone with write access to the repo can trigger a run that reads repository secrets.
A profile isolates its secrets from checks and `motor piston run`, but not from someone who can
land changes to `<MAIN>` (since deploys execute the landed `piston.star`). Only grant write access
to people you trust with production.

**NOTE:** a task with a profile only receives that profile's secrets. If it also needs a repository
secret, inherit it onto the profile with `--inherit` (step 8.3).

### 8.2 [AGENT + USER] Create profiles

Profiles take the place of GitHub environments:

- Create one profile for each GitHub environment used by a POST-LAND, RELEASE, or MANUAL job, or a
  SCHEDULED job moving to Motor.
- For a deploy or release that didn't use a GitHub environment, create a profile such as
  `production` or `release`. Create a profile for each MANUAL job as well.
- A SCHEDULED job that doesn't deploy and doesn't need environment secrets (like a nightly test)
  doesn't need a profile.

The examples below use `production`—repeat for each profile.

1. Create the profile (pass `--aws-role` only if the deploy talks to AWS):

   ```sh
   motor profiles set production --aws-role arn:aws:iam::<ACCOUNT_ID>:role/<ROLE> --repo <TEAM>/<REPO>
   ```

2. Leave the profile without rules for now; you'll bind them in step 8.6.
3. If the profile has an AWS role, fetch the OIDC trust data and follow the USER ACTION below:

   ```sh
   motor profiles oidc production --repo <TEAM>/<REPO> --json
   ```

> **USER ACTION — AWS trust**
>
> Tell the user: "In AWS IAM, do two things:
> 1. Once per AWS account, register Gauss as an OIDC identity provider:
>    `aws iam create-open-id-connect-provider --url <ISSUER> --client-id-list <AUDIENCE>`.
> 2. Attach this trust policy to `<ROLE>`:" (paste `trust_policy` from `motor profiles oidc`).
>    "Once that's in place, deploys won't need the old AWS access keys from GitHub anymore. Let me
>    know when it's set up."

**Verify:** `motor profiles show production --repo <TEAM>/<REPO> --json` shows the profile with no
rules yet.

**NOTE:** until a profile has rules, any run targeting that profile is blocked before the task
starts.

### 8.3 [USER ACTION] Enter secret values

Only a team admin can set secrets, and only a human enters the values.

> **USER ACTION — set secrets**
>
> Tell the user: "Run these commands in your own terminal. Each one prompts for the secret value
> without echoing it, so I never see it." Then list the exact commands to run, for example:
>
> ```sh
> motor secrets set npm_token --repo <TEAM>/<REPO>
> motor secrets set vercel_token --profile production --repo <TEAM>/<REPO>
> ```

Secret names use lowercase letters, digits, and underscores, starting with a letter. To share a
repository secret with a profile, have the user run
`motor secrets set <NAME> --profile production --inherit --repo <TEAM>/<REPO>`.

**Verify:**

```sh
motor secrets list --repo <TEAM>/<REPO> --json
motor secrets list --profile production --repo <TEAM>/<REPO> --json      # for each profile only
motor piston plan --credentials . --json
```

- Every expected secret name appears in the lists.
- `plan --credentials` reports `ok` as `true`. Because the check tasks from section 7 don't use a
  profile, each of their secrets shows `source` `repository`.

If you're skipping step 8.4, move on to section 9.

### 8.4 [AGENT] Write the deploy and release tasks

1. Create a workspace named `deploys`.
2. In `piston.star`, add a task for every POST-LAND, RELEASE, and MANUAL job, plus any SCHEDULED
   job moving to Motor. Give every task that deploys or uses environment secrets a `profile` (step
   8.2), and give any task that mutates a shared resource (like a deploy) a `concurrency` group so
   two runs don't collide. A nightly test with no environment secrets and no shared state needs
   neither. Read the exact source state from Piston's context instead of Git:

   ```python
   _ctx = context()
   STATE = _ctx.amp.state if _ctx.amp != None and _ctx.amp.state != None else ""

   deploy_production = task(
       name = "deploy_production",
       image = image("<IMAGE_WITH_DEPLOY_TOOLS>"),
       profile = "production",
       concurrency = "production/<SERVICE>",
       env = {"SOURCE_STATE": STATE},
       secrets = {"VERCEL_TOKEN": secret("vercel_token")},
       steps = [
           sh('[ -n "$SOURCE_STATE" ] || { echo "Start this task from a Gauss hook."; exit 1; }'),
           sh("./scripts/deploy.sh"),
       ],
       timeout = "30m",
   )
   ```

3. For a GitHub release, define an `artifact()` target (see `motor learn piston` for syntax).
4. Add a matching hook in `.gauss/hooks.star` for each task (every hook must specify an event; only
   add the hook types step 2.5 found):
   - **POST-LAND:**

     ```python
     hook(
         name = "deploy_production",
         events = ["channel.updated"],
         channels = ["<MAIN>"],
         action = piston(config = "piston.star", targets = ["deploy_production"], profile = "production"),
     )
     ```

     If the original `push` trigger used `paths` or `paths-ignore`, carry those patterns over to
     `paths` or `paths_ignore` (see Appendix B).

   - **RELEASE** (don't set `channels` on a tag hook):

     ```python
     hook(
         name = "release",
         events = ["tag.created"],
         tags = ["v*"],
         action = piston(config = "piston.star", targets = ["release"], profile = "release"),
     )
     ```

   - **MANUAL:** triggered on demand with `motor gauss hook invoke`. Because every hook still
     requires an event, use `events = ["tag.created"]` and `tags = ["manual/<HOOK>"]`, and never
     create a tag with that name.

   - **SCHEDULED:** copy the cron expressions from `on: schedule`. Use exact channel names in
     `channels` (no wildcards), and include `profile` only if the task uses one:

     ```python
     hook(
         name = "nightly",
         events = ["schedule"],
         schedules = ["<CRON>"],
         channels = ["<MAIN>"],
         action = piston(config = "piston.star", targets = ["nightly"]),
     )
     ```

5. Validate `.gauss/hooks.star` once per hook type you added:

   ```sh
   # POST-LAND
   motor gauss hook validate <TEAM>/<REPO> --dir .gauss --event channel.updated --event-channel <MAIN>
   # POST-LAND with paths or paths_ignore (test one path that should match and one that shouldn't)
   motor gauss hook validate <TEAM>/<REPO> --dir .gauss --event channel.updated --event-channel <MAIN> --event-path <PATH>
   # RELEASE
   motor gauss hook validate <TEAM>/<REPO> --dir .gauss --event tag.created --event-tag v1.0.0
   # MANUAL
   motor gauss hook validate <TEAM>/<REPO> --dir .gauss --event tag.created --event-tag manual/<HOOK>
   # SCHEDULED (once per cron expression)
   motor gauss hook validate <TEAM>/<REPO> --dir .gauss --event schedule --event-channel <MAIN> --event-schedule "<CRON>"
   ```

6. Verify credentials across all tasks: `motor piston plan --credentials . --json`.

**Verify:**

- Every `hook validate` call passes with no errors.
- Every deploy hook you added shows up as matched in one of the `hook validate` runs.
- `plan --credentials` reports `ok: true`, and `hook_only_tasks` lists every profiled task.
- Secrets on profiled tasks show `source` `owned` or `inherit`; secrets on unprofiled tasks (like
  checks) show `source` `repository`.

### 8.5 [AGENT] Land the deploy hooks

1. Land the change (LAND procedure, steps L3–L7) with the message `"Deploy from Gauss hooks"`.
2. Because the profiles have no rules yet, profiled hooks won't deploy—their invocations will fail
   saying the profile doesn't allow the event. That's expected.
3. Any `schedule` hook whose task doesn't use a profile goes live immediately after landing: Gauss
   registers its cron schedule and runs it at the next scheduled time. If scheduled times are ever
   missed (for example during an outage or repository hold), Gauss runs once for the first missed
   slot and then picks back up at the next future time. Let the user know.

**Verify:** the merge lands.

### 8.6 [AGENT + USER] Enable deploys

**WARNING:** once you bind rules in this step, deploy hooks go live. If you have a POST-LAND hook,
every merge to `<MAIN>` will deploy to production—including the merge in step 10.2.

1. List the hooks you're about to turn on and what each one does, then ask: "Good to turn these on?"
2. Once approved, bind the matching rules to each profile (hooks without a profile don't need rules):

   | Hook | Rules |
   | --- | --- |
   | POST-LAND | `--event channel.updated --pattern <MAIN>` and `--event request --pattern <MAIN>` |
   | RELEASE | `--event tag.created --pattern 'v*'` and `--event request --pattern 'v*'` |
   | MANUAL | `--event request --pattern <MAIN>` |
   | SCHEDULED | `--event schedule --pattern <MAIN>` and `--event request --pattern <MAIN>` |

   ```sh
   motor profiles bind production --event channel.updated --pattern <MAIN> --repo <TEAM>/<REPO>
   motor profiles bind production --event request --pattern <MAIN> --repo <TEAM>/<REPO>
   ```

3. Ask the user which deploy hook (if any) they'd like to trigger manually as a test (a `schedule`
   hook works too, with or without a profile). If they want to skip a live test for now, note that
   in the report and move on to section 9.
4. Trigger the chosen hook and wait for it (`<HOOK>` is the hook name, and `<INVOCATION_ID>` is
   `invocation.id` from `hook invoke`). For a RELEASE hook, pass `--tag <TAG>` with an existing tag
   from the user instead of `--channel <MAIN>`:

   ```sh
   motor gauss hook invoke <TEAM>/<REPO> <HOOK> --channel <MAIN> --json
   motor gauss invocation wait <TEAM>/<REPO> <INVOCATION_ID>
   ```

**Verify:** `motor profiles show <PROFILE> --repo <TEAM>/<REPO> --json` lists the bound rules for
each profile. If you ran a test hook, `invocation wait` exited `0` and you asked the user to check
production.

**If not:** unbind the rules (`motor profiles unbind …` with the same flags), inspect the logs
(step L6), and report back to the user.

---

## 9. Notifications

The signed-in user must be a team admin to run these commands.

### 9.1 [AGENT + USER] Connect Slack

Only run this step if the team uses Slack; otherwise skip to step 9.2.

1. Run `motor slack install-link --team <TEAM>`.
2. Follow the USER ACTION below.

> **USER ACTION — install the Slack app**
>
> Tell the user: "Send this link to someone who can install apps in your Slack workspace: `<LINK>`.
> It's single-use and valid for 7 days. Let me know once the app is installed."

3. Once `motor slack workspaces --team <TEAM>` lists the workspace, ask the user which channel to
   post to and subscribe it:

   ```sh
   motor slack subscribe --team <TEAM> --create-channel <SLACK_CHANNEL> --repository <TEAM>/<REPO>
   ```

   Without `--event`, the channel gets the default Slack events: landings on `<MAIN>`, merges
   opened or rejected, releases published or deleted, and jobs started, succeeded, or failed
   (including errors and timeouts). Run `motor slack events` to list all event types. Passing
   `--repository` scopes the subscription to that repo.

**Verify:** `motor webhooks list --team <TEAM> --json` includes a `slack_app` webhook.

### 9.2 [USER ACTION] Replace integrations with webhooks

For every integration the user chose to replace in step 2.10, draft the webhook command. Because
`motor webhooks create` prints the webhook's signing secret once, a human has to run it (R6).

> **USER ACTION — create webhooks**
>
> Tell the user: "Run these commands in your own terminal. Each one prints a signing secret once,
> which you'll paste into the receiving service." Then list the exact commands, for example:
>
> ```sh
> motor webhooks create --team <TEAM> --to https://<RECEIVER_URL> --event gauss.merge.rejected --repository <TEAM>/<REPO>
> ```

**Verify:** `motor webhooks list --team <TEAM> --json` lists every webhook.

---

## 10. Agent instructions

### 10.1 [AGENT] Replace Git and GitHub instructions

1. Create a workspace named `motor-agent-instructions`.
2. Update every file from step 2.8 to use the Motor workflow:
   - "branch" becomes "channel"; "commit" becomes "record a change" (`amp record`).
   - "pull request" becomes "merge" (`motor gauss merge create`, then `merge wait`).
   - "CI" or "GitHub Actions" becomes "Piston checks" (`motor piston run . <TARGET>`).
   - Remove `git` and `gh` commands, along with commit-message rules that conflict with the Motor
     section.
3. **Don't** edit anything between `<!-- motor:start -->` and `<!-- motor:end -->`—`motor init`
   manages that block.
4. If `CLAUDE.md` exists, update it the same way and add this line if it isn't already there:

   > Follow the "Performing work" section in `AGENTS.md` for version control, checks, and landing
   > work.

   Don't duplicate the Motor section in `CLAUDE.md`, and don't create a new `CLAUDE.md` (Claude
   Code already reads `AGENTS.md`).
5. Update the other instruction files from step 2.8 (`GEMINI.md`, `.cursor/rules/*`, agent commands
   and skills, `CONTRIBUTING.md`).
6. Update any remaining Git-dependent tools from step 2.7 that weren't covered by checks.
7. Delete `.github/workflows/` and `.github/copilot-instructions.md`, keeping any workflows the user
   chose to leave on GitHub in step 2.10. Delete `.github/dependabot.yml`, and remove `.github/`
   altogether if it's now empty.

**Verify:**

```sh
grep -rnE 'git (commit|push|checkout|switch|rebase|merge)|gh pr|pull request|GitHub Actions' \
  --include='*.md' --include='*.mdc' --include='.cursorrules' . | grep -v '^./workspaces/'
```

No active instructions to use Git or GitHub remain (historical mentions like "this project moved
from GitHub" are fine).

### 10.2 [AGENT] Land the updated instructions

Land the change (LAND procedure, steps L3–L7) with the message `"Use Motor in the agent
instructions"`.

**Verify:** the merge lands and every required check passes.

### 10.3 [USER ACTION] Smoke-test the workflow in a fresh session

1. Configure your default human attribution on this machine so Amp stamps `on_behalf_of` on every
   change:

   ```sh
   amp config set author.for "<USER_NAME> <<USER_EMAIL>>"
   ```

2. Follow the USER ACTION below.

> **USER ACTION — smoke test**
>
> Tell the user: "Start a **fresh** session of each coding agent your team uses inside `<REPO_DIR>`
> and give it this prompt:
>
> *Read the project instructions. Fix one small thing in this repository (like a typo in a comment)
> and land it on `<MAIN>`.*
>
> Let me know once each session finishes."

**Verify:** for each session, confirm:

1. `amp log -n 5 --json` shows the change with `author.name`, `author.model`, and `on_behalf_of`.
2. `motor gauss merge list <TEAM>/<REPO> --status merged --json` shows the merge.
3. `amp workspace list --json` shows no leftover workspace from that session.
4. `amp channel list --json` shows no leftover local channel from that session.

**If not:** figure out which instruction the agent missed, tighten the instruction file, land the
fix, and have the user run the smoke test again.

---

## 11. Retire GitHub

### 11.1 [AGENT] Categorize GitHub credentials

**WARNING:** if someone copied the same credential to both GitHub and Motor (step 8.3), revoking it
upstream will break Motor checks, deploys, or releases that depend on it.

1. Gather every credential tied to the GitHub repo:
   - Every GitHub secret from step 2.6 and its upstream source (for example, a cloud console or npm
     token).
   - Every AWS access key replaced by a profile IAM role in step 8.2.
   - Every deploy key: `gh api repos/<GH_REPO>/keys --jq '.[].title'`.
   - Every AWS role trusting GitHub OIDC.
   - Every webhook from step 2.9.
2. Assign each credential a status and log it in the report:

| Status | When it applies | What the user does |
| --- | --- | --- |
| KEEP-GITHUB | Still used by a job or integration left on GitHub (step 2.10) | Keep it active. |
| SHARED | Motor uses the exact same credential (entered in step 8.3) | Don't revoke it yet. Rotate it first (below). |
| REPLACED | Motor uses a different credential for the same work (such as a profile's AWS role instead of static keys), and that work has already passed on Motor | Revoke it. |
| UNUSED | Nothing uses it anymore | Revoke it. |

3. Only mark a credential REPLACED after its Motor equivalent has actually passed (a check in step
   7.4 or a deploy in step 8.6). Otherwise mark it SHARED or KEEP-GITHUB and flag it for the user.

**Rotating a SHARED credential:** have the user mint a fresh credential upstream and save it in
Motor (`motor secrets set`, step 8.3). Run the task that uses it (`motor piston run` for a check or
`motor gauss hook invoke` for a deploy) and confirm it passes, then have the user revoke the old
one.

### 11.2 [USER ACTION] Revoke credentials and archive GitHub

**WARNING:** don't archive `<GH_REPO>` if any workflow still runs on GitHub Actions (step 2.10)—an
archived repo stops running workflows.

> **USER ACTION — retire GitHub**
>
> Tell the user: "Everything is up and running on Motor. Here's the final cleanup on GitHub:
>
> 1. Revoke each credential with the status REPLACED or UNUSED in the report at its source. Leave
>    anything marked SHARED or KEEP-GITHUB alone.
> 2. Remove GitHub OIDC trust from any AWS role that now trusts Motor (unless a job staying on
>    GitHub still uses it).
> 3. Remove the webhooks and GitHub apps Motor replaced.
> 4. Add a banner at the top of the GitHub README: 'This repository moved to
>    https://gauss.motor.dev/<TEAM>/<REPO>.'
> 5. Archive `<GH_REPO>`, unless a workflow still needs to run on GitHub.
>
> If you'd like, I can delete the webhooks (3), update the README (4), and archive the repo (5)
> with `gh`. GitHub apps have to be removed in GitHub's web settings."

If approved, run those steps—updating the README (4) before archiving (5), since archived repos are
read-only:

```sh
gh api -X DELETE repos/<GH_REPO>/hooks/<HOOK_ID>
gh repo archive <GH_REPO> --yes
```

---

## 12. Final verification

### 12.1 [AGENT] Verify team membership

```sh
motor members list --team <TEAM> --json
motor invites list --team <TEAM> --json
```

**Verify:** everyone in `<ADMINS>` and `<MEMBERS>` is a member with the right role.

**If not:** let the user know who hasn't accepted yet (teammates sometimes accept with a different
email, so check any missing addresses with the user) and pass along Appendix A for anyone still
pending. Pending invites don't block wrapping up the migration.

### 12.2 [AGENT] Verify the repository

Run every check and log the outcome in the report:

| Check | Command | Expected result |
| --- | --- | --- |
| Team access | `motor gauss repo access show <TEAM>/<REPO> --json` | Team scopes `read`, `write` |
| Required checks | `motor gauss policy show <TEAM>/<REPO> <MAIN> --json` | Every check from 7.5 listed; direct pushes forbidden |
| Hooks | `motor gauss hook list <TEAM>/<REPO> --channel <MAIN> --json` | A hook for every check, deploy, and release |
| Secrets | `motor piston plan --credentials . --json` | `ok` is `true` |
| Profiles | `motor profiles list --repo <TEAM>/<REPO> --json` | Every profile enabled, with rules scoped only to `<MAIN>` or release tags |
| Recent landings | `motor gauss invocation list <TEAM>/<REPO> --json` | Latest check and deploy invocations passed |
| Instructions | The `grep` command from step 10.1 | No Git or GitHub instructions |
| GitHub | `gh repo view <GH_REPO> --json isArchived` | `true`, unless kept active by choice |

### 12.3 [AGENT] Deliver the final report

Hand `<WORK_DIR>/report.md` to the user and summarize:

1. The new repository URL: `https://gauss.motor.dev/<TEAM>/<REPO>`.
2. Anything that couldn't be imported (step 5.2).
3. Required checks, plus the deploy and release hooks now active.
4. Anything that stayed behind (unmigrated SCHEDULED jobs, UNSUPPORTED jobs, integrations, issues)
   and what was decided for each.
5. Anyone who still hasn't accepted their team invite.
6. A reminder that the old Git checkout is retired—everyone should clone fresh with `amp clone`
   (Appendix A).

The migration is complete.

---

## Appendix A: Setup for each team member

Send this appendix to everyone on the team. Run these steps on every machine you work from.

1. Accept your invite from the Motor email (invites expire after 7 days). Sign in with Google, add
   a passkey, and pick your handle.
2. Install Amp and the Motor CLI:

   ```sh
   curl -fsSL https://gauss.motor.dev/motor/amp/artifacts/install.sh | sh
   curl -fsSL https://gauss.motor.dev/motor/cli/artifacts/install.sh | sh
   ```

3. Confirm `amp --version` prints `amp YYYY_MM_NNNN`. If it prints something else, a different
   program named `amp` is earlier on your `PATH`.
4. Sign in with `motor auth` (or `motor auth --device` on a headless machine).
5. Set your human attribution so Amp records your name on changes your agents make:

   ```sh
   amp config set author.for "<YOUR_NAME> <<YOUR_EMAIL>>"
   ```

6. Clone the repository:

   ```sh
   amp clone https://gauss.motor.dev/<TEAM>/<REPO> --channel <MAIN>
   ```

7. Stop using your old Git checkout for new work. If you have unmerged local work there, carry it
   over as a patch:

   ```sh
   cd <OLD_GIT_CHECKOUT>
   git diff --binary <MAIN>...<YOUR_BRANCH> > ~/my-work.patch
   cd <NEW_AMP_CLONE>
   amp workspace add workspaces/my-work
   cd workspaces/my-work
   git apply ~/my-work.patch
   ```

   `git apply` works even outside a Git repo. Once it applies cleanly, ask your agent to record and
   land the change.
8. Your coding agents pick up the Motor workflow automatically from `AGENTS.md`—no extra agent
   setup needed.

## Appendix B: Translate GitHub Actions to Piston

| GitHub Actions | Piston (`piston.star`) |
| --- | --- |
| `runs-on: ubuntu-latest` | `image = image("<image>")` (defaults to `linux/amd64`) |
| `runs-on: ubuntu-24.04-arm` | `platform = "linux/arm64"` |
| `runs-on: windows-latest` | `platform = "windows/amd64"`. No caches, `docker()`, or `layer()`. `sh()` runs `pwsh`. |
| `runs-on: macos-*` | Not available |
| `actions/setup-node`, `setup-python`, `setup-go` | Pick an image with the toolchain installed, like `image("node:22-bookworm")` |
| Repeated install steps | `layer(<image>, name = "...", steps = [apt([...])])` |
| `services: postgres` | `layer(<Debian or Ubuntu image>, name = "...", steps = [apt(["postgresql"]), postgres_configure(trust_local = True)])`, plus `postgres_start()` as the first step (`@piston//postgres.star`) |
| Other `services:` containers | `docker = docker(cache = "...")` and `docker run` in a step |
| `strategy.matrix` | A list comprehension of `task()` calls |
| `actions/cache` | `caches = {"<absolute path>": "<key>"}` (commands must still work on a cold cache) |
| `upload-artifact` / `download-artifact` | `outputs = {...}` and `inputs = {"<path>": other.output("<name>")}` |
| `needs:` | `needs = [other_task]` |
| `concurrency:` | `concurrency = "<group>"` (tasks with a profile only) |
| `timeout-minutes` | `timeout = "30m"` (12 hours max) |
| `secrets.X` | `secrets = {"X": secret("x")}` |
| `vars.X` | `env = {"X": "<value>"}` |
| `environment: production` | `profile = "production"` |
| `GITHUB_TOKEN` | `secret("gauss_invocation_token")` in hook runs only. Scoped to pushing and publishing in its own repo, and expires 10 minutes after the run ends. No equivalent for GitHub API calls. |
| `GITHUB_SHA` | `context().amp.state` (in a hook run) |
| `uses: some/action@v1` | Run the underlying commands directly as `sh()` steps |
| JUnit or `go test -json` reports | `report = junit("<glob>")` or `report = go_test_json("<file>")` |
| `on: pull_request` | Hook on `merge.candidate_updated` with `check = "<name>"` |
| `on: push` to the default branch | Hook on `channel.updated`, `channels = ["<MAIN>"]` |
| `on: push: tags` / `on: release` | Hook on `tag.created`, `tags = ["v*"]` |
| `paths:` on `push` or `pull_request` | `paths = [...]` with the same patterns in the same order (`!` negates, just like GitHub) |
| `paths-ignore:` on `push` or `pull_request` | `paths_ignore = [...]` with the same patterns |
| `paths` with `?` or `+` (like `*.jsx?`) | Same pattern: `?` matches zero or one of the preceding character, `+` matches one or more |
| `paths` with `[...]`, `{...}`, or `\` escapes | Not supported—expand into separate patterns using `*`, `**`, `**/`, `?`, and `+` |
| Required check skipped by `paths` (hangs forever on GitHub) | Marked `skipped`, so the merge still lands |
| `paths` on `push: tags` or `schedule` | Not supported (Gauss doesn't filter paths on `tag.created` or `schedule`) |
| `on: workflow_dispatch` | `motor gauss hook invoke <TEAM>/<REPO> <HOOK> --channel <MAIN> --input name=value` |
| `on: schedule` | Hook on `schedule`, `schedules = ["<cron>"]` (5 fields, UTC, at least 5 minutes apart, Sunday is `0`), `channels = ["<MAIN>"]` (exact names) |
| Branch protection and required status checks | `motor gauss policy set ... --require <check> --forbid-direct-pushes` |
| Required reviewers, CODEOWNERS | Not available. Use `motor gauss merge create --draft` to hold a change for human review. |
