Claude Code skill

The one-repo method

My lessons from building clrframe with AI, packaged as a Claude Code skill that sets up your next AWS project the same way.

For over five years I was the code guy, writing every line by hand. Building clrframe with AI taught me that how you set up a project matters more than any single piece of code. This skill sets up a new AWS app the same way: the frontend, the backend, the infrastructure, the database, CI/CD, the docs, and the rules the AI follows, all in one GitHub repo.

zip
35 files · 8,738 lines · 201 KB
SHA-256
3fd302e87c1d9f931e2b9dd0ab6e441690e768d29f8cac5591dc5ba46215a01d
  • MIT license
  • For Claude Code
  • Builds on AWS with CDK

what it sets up

  1. Keep everything in one repo
  2. The AI can only work with what it can see
  3. Make every change one pull request
  4. Let the database change with the code
  5. If it's all written down, you can turn it off
  6. Every mistake becomes a guardrail

your-app/

lesson 01: Keep everything in one repo

Everything below lives in one repo.

The code, the servers, the database, DNS and alarms are all written as code and live next to the app, the docs and the AI's instructions.

your-app/frontend/

the web app (Angular by default)

lesson 02: The AI can only work with what it can see

The button the bug starts at is here, in the same repo as the cloud permission.

With everything in one repo, it can follow a bug from a button all the way to a cloud permission.

your-app/backend/

TypeScript Lambda functions

lesson 04: Let the database change with the code

Migrations live next to the code that uses them and run on every deploy.

Schema changes run on every deploy, and if one fails the whole deploy rolls back.

your-app/shared/

types every layer imports

lesson 03: Make every change one pull request

Types every layer imports, so one PR changes them together.

The screens, the API, the database change and the docs go in together, reviewed and tested together.

your-app/cdk/

all AWS infrastructure as code

lesson 05: If it's all written down, you can turn it off

The pause switch is a flag in this code.

A pause switch shrinks the app down to just the website, and one deploy brings it all back.

your-app/docs/

flow diagrams and decision records

lesson 03: Make every change one pull request

Updated in the same PR as the change.

The screens, the API, the database change and the docs go in together, reviewed and tested together.

your-app/.github/

tests on every PR, deploy on merge

lesson 06: Every mistake becomes a guardrail

Tests on every PR catch what broke before.

When something breaks, fix it, then add a test, a rule or a runbook so it doesn't happen again.

your-app/.claude/

runbook skills for the AI

lesson 06: Every mistake becomes a guardrail

Runbook skills written after real incidents.

When something breaks, fix it, then add a test, a rule or a runbook so it doesn't happen again.

your-app/CLAUDE.md

the rules the AI follows

lesson 02: The AI can only work with what it can see

The rules the AI reads before every change.

With everything in one repo, it can follow a bug from a button all the way to a cloud permission.

your-app/README.md

how it all works, kept current

lesson 03: Make every change one pull request

Kept current in the same PR.

The screens, the API, the database change and the docs go in together, reviewed and tested together.

your-app/PROJECT_SPEC.md

what the system is, kept current

lesson 03: Make every change one pull request

Kept current in the same PR.

The screens, the API, the database change and the docs go in together, reviewed and tested together.

01 / process

How it works

  1. Look

    Checks what is already on your machine and in the folder. Read-only.

  2. Interview

    Asks the decisions in rounds, each with a recommended answer, then waits for your OK.

  3. Build

    Writes each layer in order and checks each one before moving on.

  4. Verify

    Runs every test and a CDK synth, then breaks things on purpose to prove the checks catch it.

  5. Hand off

    Writes a setup script for the AWS and GitHub steps only you should run.

02 / limits

What it won't do

  • Run AWS commands that change anything. You run those, from a script you can read.

  • Store keys. Deploys use short-lived GitHub OIDC credentials.

  • Turn off Claude Code's permission prompts.

  • Deploy without asking. Merging the first pull request is your call.

03 / install

Install

  1. curl -fsSL https://jameschristensenresume.com/skills/one-repo-aws.zip -o one-repo-aws.zip
  2. unzip one-repo-aws.zip -d ~/.claude/skills/
04 / files

Read it before you install.

Skills run with your permissions, so here is every file.

SKILL.md348 lines
---
name: one-repo-aws
description: "Sets up a new AWS web app in one GitHub repo: frontend, Lambda API, CDK infrastructure, migrations on deploy, OIDC CI/CD, docs and CLAUDE.md rules. Use when starting a new AWS project."
license: MIT
metadata:
  author: James Christensen
  version: "1.0.0"
---

# Build a web app on AWS from one repo

The human ends up with one GitHub repo that holds the frontend, a TypeScript Lambda API, AWS CDK
infrastructure, database migrations that run inside the deploy, GitHub Actions CI/CD over OIDC, living docs,
a CLAUDE.md and runbook skills. Merging to main deploys prod. The method comes from building clrframe
(clrframe.com), and every step below serves one of its six lessons; each phase names the ones it serves:

1. Everything lives in one GitHub repo, infrastructure as code included.
2. The agent works only with what it can see: one repo lets it follow a bug from a button to a cloud permission.
3. One change is one PR that covers every layer it touches: UI, API, infra, database, docs.
4. The database changes with the code: migrations run on every deploy, and a failed one rolls the deploy back.
5. Written down means you can turn it off: the pause switch shrinks prod to the static site and its data.
6. When something breaks, fix it, then add a test, a rule or a runbook so it cannot happen again.

## How this skill works

Copy this checklist into your first reply and keep it current:

```
Setup progress:
- [ ] 1. Look: read-only preflight done, findings summarized
- [ ] 2. Interview: every decision answered, plan confirmed by the human
- [ ] 3. Write: CLAUDE.md, README.md, PROJECT_SPEC.md drafts approved; P1-P8 built in order
- [ ] 4. Verify: every "Done when" met, each check seen failing once, check-repo.sh passes
- [ ] 5. Hand off: scripts/setup-wizard.sh generated and checked, next commands printed
```

### 1. Look (read-only)

Run this before asking anything, and change nothing:

```bash
pwd; git rev-parse --show-toplevel; git status --short; git remote -v; ls -A
node --version; npm --version; git --version; gh --version; aws --version; docker --version
gh auth status
for p in $(aws configure list-profiles); do printf '%s ' "$p"
  aws sts get-caller-identity --profile "$p" --query Account --output text </dev/null 2>/dev/null || echo 'no session'
done
```

- Read any existing CLAUDE.md, README.md and package.json files before planning.
- Report each profile's account. Never call AWS without `--profile`: the default credential chain can answer
  for an unrelated account. "no session": record it and go on. Never ask for access keys.
- Your AWS access is a read-only profile per account (ReadOnlyAccess or ViewOnlyAccess, named like
  `<app>-prod-readonly`). Until the human creates them, use existing profiles only for interview.md's
  read-only lookups, and add "create the read-only profiles" to the plan's human-only steps.
- A tool is missing: say what it blocks. Without gh the wizard cannot run; without Docker only the Postgres
  integration tests skip. Local Node is not an LTS: say so; builds still work. The Lambda runtime and CI's
  `NODE_VERSION` come from infrastructure.md section 7's `NODEJS_` grep, never from the local version.
- Uncommitted changes, or a parent repo that is not this project: stop and ask.
- Existing app: map its parts onto frontend/, backend/, shared/ and cdk/, and plan the moves with
  `git mv` so history follows. Delete nothing the human wrote without asking.
- Re-runs update in place and never duplicate. In CLAUDE.md, everything this skill owns sits between
  `<!-- one-repo-aws:start -->` and `<!-- one-repo-aws:end -->`; replace only the inside. For any other
  existing file, show a diff and merge.

End with a short summary: what exists, what is missing, what blocks.

### 2. Interview in rounds

Read [references/interview.md](references/interview.md) and run its rounds in order; later ones depend on earlier.

- Ask only decisions. Look facts up yourself with the read-only calls interview.md lists, `--profile` on each.
- Lead every question with the recommended default and a one-line reason, then the escape hatch, so
  "yes" accepts it. Keep each round short; interview.md sets what goes in it.
- Then stop. Show one table with every decision and its answer, plus the git plan (new folder: a seed commit
  of README.md and .gitignore on main, all other work on `chore/scaffold`). Write nothing until it is confirmed.

### 3. Propose, then write

1. Draft CLAUDE.md, README.md and PROJECT_SPEC.md from the templates, filled with the plan, and show them in
   your reply. They are the contract for everything that follows; P1 writes them once the human approves.
2. Build P1-P8 in order (see Build order). Read the phase's reference first, and start a phase only when
   the previous phase's "Done when" holds.
3. Beyond the seed commit in the confirmed plan, commit only when the human asks. One commit per phase
   makes a readable history.

### 4. Verify

- Run each phase's "Done when" checks and quote the passing lines as evidence. When a reference ends with
  its own "Done when" commands, run those too.
- Prove every new check can fail: break what it guards, run it, see it fail for the expected reason,
  revert, see it pass. A check never seen failing proves nothing. Faults to use:

| Check | Deliberate fault |
|---|---|
| `cdk/test/spa-rewrite.test.mjs` | let the function rewrite asset paths such as `/main.js` |
| CDK template tests | attach the deep-link function to the `/api/*` behavior |
| Stateful-id test (`cdk/test/stateful-ids.json`) | rename the site bucket's construct id |
| Credential-free synth | add a `HostedZone.fromLookup` call |
| Paused-mode template test | move the API outside the pause guard |
| Backend tests | make `/api/health` return `{ ok: false }` |
| Docs check (ci.yml `docs` job) | link README.md to `docs/missing.md` |
| Wizard coverage (step 5) | read a new `vars.NEW_VAR` in a workflow |

- Then run the bundled validator until it reports no FAIL:

```bash
bash <skill-dir>/scripts/check-repo.sh <path-to-new-repo>
```

`<skill-dir>` is the folder this SKILL.md was loaded from, usually `~/.claude/skills/one-repo-aws`. The script
is read-only, prints PASS/WARN/FAIL lines and a summary, and exits 1 on any FAIL. Fix every FAIL; put every
WARN to the human as a question, except two expected ones: the wizard "is not generated yet" (until step 5)
and unfilled `<prod-url>` or `<dev-url>` (until the first deploy).

### 5. Hand off

1. Generate `scripts/setup-wizard.sh` from its template with the plan's values. It holds the human-only steps:
   the OIDC deploy role stack for each stage, in that stage's account (a change set the human reviews first),
   CDK bootstrap, the account budget, repo variables and the ruleset on main; GitHub environments only with
   that escape hatch. [references/aws-setup.md](references/aws-setup.md) explains each one, plus the
   read-only profiles the human creates for you. Check it:

```bash
bash -n scripts/setup-wizard.sh && { ! command -v shellcheck >/dev/null || shellcheck scripts/setup-wizard.sh; }
for v in $(grep -ohE 'vars\.[A-Z0-9_]+' .github/workflows/*.yml | sed 's/^vars\.//' | sort -u); do
  grep -qw "$v" scripts/setup-wizard.sh || echo "wizard never sets $v"; done
grep -ohE 'secrets\.[A-Z0-9_]+' .github/workflows/*.yml | grep -v GITHUB_TOKEN   # must print nothing
```

   Then re-run `bash <skill-dir>/scripts/check-repo.sh .` until it reports no FAIL. The wizard takes the
   ruleset's required checks from the ci.yml job ids; if you set `REQUIRED_CHECKS`, it must equal them.
   Renaming a job later blocks every merge until the ruleset changes too.

2. Print the human's next commands in order, leaving out any that already ran:

```bash
gh repo create <ORG>/<REPO> --private --source . --remote origin   # new repo only
git push -u origin main                                              # new repo only: the seed commit
bash scripts/setup-wizard.sh   # in their own terminal: it asks y/N before each step and can resume
git add -A && git commit -m "feat: scaffold the app"                 # on chore/scaffold, if uncommitted
git push -u origin chore/scaffold && gh pr create --base main
```

3. Push and open the first PR only when the human asks. Its Merge danger section says: do not merge until
   the wizard reports every step done, because merging deploys prod for the first time.

## Build order

Copy this checklist as well:

```
Build progress:
- [ ] P1 Skeleton + agent context (lessons 1, 2). Done when: P1 templates copied and filled, one marked section in CLAUDE.md
- [ ] P2 shared/ contracts (lesson 3). Done when: shared/ imports nothing from outside shared/
- [ ] P3 Infrastructure (lessons 1, 5). Done when: the ci.yml infra synths (default, paused, all flags) and their tests pass with no AWS credentials
- [ ] P4 Backend (lesson 3). Done when: backend npm test and typecheck pass, and the P3 synths still pass
- [ ] P5 Database, if chosen (lesson 4). Done when: migrations run on a throwaway Postgres (or SKIP loudly); synth shows the migrate resource
- [ ] P6 Frontend (lesson 3). Done when: build and headless tests pass, only relative /api calls, synth passes on the real build
- [ ] P7 CI/CD (lessons 3, 4). Done when: workflows lint clean and read only the contract variables, with no secrets
- [ ] P8 Docs pass (lessons 2, 6). Done when: the docs check passes, the first ADR exists, check-repo.sh shows no FAIL
```

**P1 Skeleton + agent context (lessons 1, 2).** Read [repo-layout.md](references/repo-layout.md) and
[agent-context.md](references/agent-context.md).
- Existing repo: `git fetch origin && git switch -c chore/scaffold origin/main`.
- New folder: `git init -b main`, write `.gitignore` and README.md, and commit just those two as the
  seed on main (the confirmed plan covers this commit). Then `git switch -c chore/scaffold`. Workflows
  reach main only through a PR, because a push to main deploys prod.
- Create the top-level folders; frontend/, backend/ and cdk/ are independent npm projects (no root
  package.json, no workspaces).
- Write the approved CLAUDE.md, README.md and PROJECT_SPEC.md. Copy the other P1 templates (see Templates)
  and fill `<app>` (kebab slug), `<App>` (PascalCase), `<ORG>/<REPO>`, `<region>`, `<PROD_READONLY_PROFILE>`
  / `<DEV_READONLY_PROFILE>` (the agent's read-only profiles from the plan), `<license>` ("Proprietary. All
  rights reserved." unless the human names one) and the account ids. An id nobody could look up: write
  "unverified (the wizard prints it)", then the real id after the wizard's first run. `<prod-url>` and
  `<dev-url>` wait for the first deploy.
- A runbook skill's last line stays "Not yet verified" unless you ran what it describes during setup.
- Done when every P1 row of the Templates table, `.gitignore` and the top-level folders exist, CLAUDE.md
  has exactly one start and one end marker, and this prints nothing:
  `grep -rnE '<(app|App|ORG|REPO|region|license|PROD_ACCOUNT_ID|DEV_ACCOUNT_ID|PROD_READONLY_PROFILE|DEV_READONLY_PROFILE)>' --exclude-dir=node_modules --exclude-dir=.git --exclude-dir=one-repo-aws .`

**P2 shared/ contracts (lesson 3).** Read [repo-layout.md](references/repo-layout.md). Framework-free TypeScript
for whatever crosses a layer boundary: API request and response types, route paths, the `config.json` shape.
No package.json inside shared/; backend and cdk tsconfig include `../shared/**/*.ts`. P3, P4 and P6 prove
that each layer compiles against it. Done when this prints nothing (imports stay inside shared/):
`grep -rnE "from ['\"](\.\./|[^.'\"])" shared/`.

**P3 Infrastructure (lessons 1, 5).** Read [infrastructure.md](references/infrastructure.md), then skim
[lessons-learned.md](references/lessons-learned.md).
- Create `cdk/bin/app.ts` (throws without `-c stage`; one stack `<App>-<stage>`; region from
  `CDK_DEFAULT_REGION ?? AWS_REGION`), `cdk/lib/app-stack.ts`, one NestedStack per feature area
  (`cdk/lib/<feature>-stack.ts`), a private S3 bucket behind CloudFront (OAC) with the `/api/*` behavior and
  the deep-link function, the REST API with the health Lambda, cert and DNS only with a domain, per-stage
  removal policies, the pause switch, monitoring, the `SiteUrl` output and the template tests.
- `NodejsFunction` bundles handlers at synth with the esbuild in backend/, and asset staging needs the
  frontend build folder. Before the first synth, initialize backend/ as backend.md section 1 does (esbuild is
  a devDependency of both backend/ and cdk/), add a stub `src/handlers/health.ts`, run `npm install` there,
  and create the frontend build folder with a placeholder index.html.
- Copy `templates/cdk/stateful-ids.json` (it lists the site bucket). After the first full synth, run the
  template tests: the stateful-id test prints an entry for each unlisted bucket, user pool, table and
  database instance. Add them and commit, so renaming a stateful construct id fails CI instead of
  replacing live data.
- Done when the ci.yml template's `infra` job passes from cdk/ with no AWS credentials: its three synths
  (default `-c stage=dev`; paused, adding `-c paused=true`; every optional flag on, with placeholder values),
  each into its own `--output` folder and followed by `CDK_OUT=<that folder> npm test`. Copy
  `templates/noaws.sh` to `scripts/noaws.sh` (fill `<region>`) and run each synth through it, one command
  per call as the verify runbook skill writes it, such as
  `bash ../scripts/noaws.sh npx cdk synth -c stage=dev --output cdk.out/default --quiet`; run
  `CDK_OUT=cdk.out/default npm test` outside it (its `env -i` drops `CDK_OUT`). All six lines:
  infrastructure.md section 19.

**P4 Backend (lesson 3).** Read [backend.md](references/backend.md). Create `backend/src/handlers/health.ts`
(`GET /api/health`, no auth, returns `{ ok: true }`), `backend/src/lib/logger.ts`, the Jest setup, and tests
that call each handler through its exported entry point. Done when `npm test` and `npm run typecheck` pass
in backend/ and the P3 synths still pass.

**P5 Database, if chosen (lesson 4).** Read [database.md](references/database.md). None: skip it and say so
in PROJECT_SPEC.md.
- Postgres: VPC, RDS Postgres with IAM auth (prod `RemovalPolicy.SNAPSHOT`), `backend/src/db/`
  (`connection.ts`, `migrate.ts`, `migrate-resource.ts`, `seed.ts`, `migrations/` with only
  `0001_create_settings.ts`, the table the seed fills), a migrate custom resource keyed on a hash of the DB
  sources, and a DB check in `/api/health`. Paused mode keeps the VPC and the instance
  (smallest class) and drops the NAT gateway, RDS Proxy and Lambdas, so a resume finds the data. Done when
  the migration tests run against a throwaway Postgres (Testcontainers) or print a loud SKIP without Docker,
  the template has the migrate custom resource, and the paused one keeps the instance but no NAT gateway.
- Opt-in `-c pauseDropsDatabase=true` deletes the instance through a final snapshot; the pause-prod runbook
  skill refuses it until a tested restore runbook skill exists (database.md, "Restore after a resume").
- DynamoDB: the table with its per-stage removal policy, outside the pause gate, plus data-access code.
  Done when the table is in both templates and the data-access tests pass.

**P6 Frontend (lesson 3).** Read [frontend.md](references/frontend.md). Angular standalone from its
official CLI (escape hatch: React + Vite) in frontend/. It calls only relative `/api`, reads stage values
from `/config.json` (written by the stack) and shows the paused banner when that file says `paused: true`.
Point the build-output constant in `cdk/lib/app-stack.ts` at the real output folder. Done when
`npm run build` and `npm test` (headless, single run) pass in frontend/, no absolute API URL appears
under `frontend/src`, and the P3 synths pass against the real build.

**P7 CI/CD (lessons 3, 4).** Read [ci-cd.md](references/ci-cd.md). Copy the workflow templates,
`dependabot.yml` and the OIDC role template.
- `deploy.yml` is the only deploy workflow. A push to main deploys prod; a manual run deploys the stage it is
  given (`gh workflow run deploy.yml -f stage=dev --ref <branch>`), and a guard step fails `stage=prod` off
  main. Its `test` job runs every suite with no AWS credentials; only the `deploy` job, which needs it, can
  request the OIDC token; the `tag` job tags pushes to main. Copy `destroy-stage.yml` only when a dev stage
  exists; its allowlist names non-prod stages only.
- The prod role trusts only `repo:<ORG>/<REPO>:ref:refs/heads/main`, the dev role any branch of the repo
  (`ref:refs/heads/*`); that works on every GitHub plan. One account for both stages: the dev role reaches
  the same cdk-* roles as prod, so it trusts main only, and dev deploys only from main. Escape hatch for
  public repos or paid plans: GitHub environments with protection rules, `SubjectMode=environment` on the
  role stacks, `environment: <stage>` on the deploy job.
- Workflows read only these repo variables: `AWS_REGION`, `AWS_DEPLOY_ROLE_ARN_PROD`,
  `AWS_DEPLOY_ROLE_ARN_DEV` (dev stage only), `APP_DOMAIN`, `HOSTED_ZONE_ID`, `HOSTED_ZONE_NAME` (domain
  only), `ALARM_EMAIL` (optional). No secrets.

Done when `actionlint` passes (without it, `npx --yes js-yaml <file> >/dev/null` parses each workflow);
`grep -rhoE '(vars|secrets)\.[A-Z0-9_]+' .github/workflows | sort -u` shows only those names (plus, at most,
`secrets.GITHUB_TOKEN`); the OIDC template passes `cfn-lint` or the read-only
`aws cloudformation validate-template --profile <PROD_READONLY_PROFILE> --region <region> --template-body file://infra-bootstrap/github-oidc-deploy-role.yaml`;
and check-repo.sh shows no FAIL for the workflows or the role template (it FAILs on a wildcard prod subject).

**P8 Docs pass (lessons 2, 6).** Read [agent-context.md](references/agent-context.md). Bring README.md and
PROJECT_SPEC.md in line with what was built: setup, stages, repo variables, the pause switch, runbook
skills, and README.md's "Infrastructure rules" (CLAUDE.md points there). Write `docs/FLOW.md` (Mermaid:
request path, deploy path, pause switch). Copy the ADR template to `docs/decisions/0000-template.md` and
write `docs/decisions/0001-<title>.md`: why migrations run inside the deploy (with no database: why
merging deploys prod). Done when the ci.yml `docs` job's check passes locally and check-repo.sh reports no
FAIL.

## Templates

Copy from `<skill-dir>/templates/`, then fill the placeholders.

| Template | Destination in the new repo | Phase |
|---|---|---|
| `CLAUDE.md` | `CLAUDE.md` | P1 |
| `README.md` | `README.md` | P1 |
| `PROJECT_SPEC.md` | `PROJECT_SPEC.md` | P1 |
| `pull_request_template.md` | `.github/pull_request_template.md` | P1 |
| `claude-settings.json` | `.claude/settings.json` | P1 |
| `runbook-skills/verify.md` | `.claude/skills/verify/SKILL.md` | P1 |
| `runbook-skills/aws.md` | `.claude/skills/aws/SKILL.md` | P1 |
| `runbook-skills/pause-prod.md` | `.claude/skills/pause-prod/SKILL.md` | P1 |
| `runbook-skills/retro.md` | `.claude/skills/retro/SKILL.md` | P1 |
| `cdk/spa-rewrite.js` | `cdk/functions/spa-rewrite.js` | P3 |
| `cdk/spa-rewrite.test.mjs` | `cdk/test/spa-rewrite.test.mjs` | P3 |
| `cdk/template.test.mjs` | `cdk/test/template.test.mjs` | P3 |
| `cdk/stateful-ids.json` | `cdk/test/stateful-ids.json` | P3 |
| `noaws.sh` | `scripts/noaws.sh` | P3 |
| `github-workflows/ci.yml` | `.github/workflows/ci.yml` | P7 |
| `github-workflows/deploy.yml` | `.github/workflows/deploy.yml` | P7 |
| `github-workflows/destroy-stage.yml` | `.github/workflows/destroy-stage.yml` (dev stage only) | P7 |
| `dependabot.yml` | `.github/dependabot.yml` | P7 |
| `aws/github-oidc-deploy-role.yaml` | `infra-bootstrap/github-oidc-deploy-role.yaml` | P7 |
| `docs-adr-template.md` | `docs/decisions/0000-template.md` | P8 |
| `setup-wizard.sh` | `scripts/setup-wizard.sh` | Step 5 |

## Rules while working

- AWS is read-only for you, through the read-only profiles: `sts get-caller-identity`, `describe-*`,
  `list-*`, `get-*` and `cloudformation validate-template`. Pass `--profile` and `--region` on every call.
- Anything that creates, changes or deletes cloud resources outside CI goes to the human as a
  `! <command>` line or a wizard step; afterwards, verify it with a read-only call. That includes
  `cdk bootstrap`, `cdk deploy` and `cdk destroy`.
- Expired or missing AWS login: hand the human `! aws sso login --profile <profile>` (or their usual
  sign-in) and stop. No retry loops, no workarounds, never ask for access keys.
- Never commit secrets, `.env` files or `.setup-wizard.state`. Never add long-lived AWS keys anywhere,
  GitHub secrets included: CI authenticates only through OIDC.
- Never enable `bypassPermissions` or suggest skipping permission prompts, in this session or in the
  generated `.claude/settings.json`.
- Ask before anything that deploys or deletes: pushing to main, merging, `gh workflow run`, the
  destroy-stage workflow, removing files the human wrote.
- One change, one PR: every layer it touches, its docs and its test go in together.
- Never rename a stateful resource's construct id (bucket, table, database, user pool): CloudFormation
  treats the new logical id as a new resource and removes the old one.
- Keep synth credential-free: no `fromLookup`; the hosted zone comes from `hostedZoneId` and `hostedZoneName`.
- One default per decision. Take an escape hatch only when the human picks it; record why in PROJECT_SPEC.md.

## After setup: the everyday loop

In the new repo, CLAUDE.md, CI and the ruleset keep every change on this loop:

1. `git fetch origin && git switch -c <type>/<slug> origin/main`. Never commit to main.
2. Change every layer the feature needs (shared/, backend, cdk, frontend) and the docs, on one branch (lesson 3).
3. Run each layer's tests and the credential-free synths from ci.yml (lesson 3).
4. Open a PR from the template: Summary, Evidence, Merge danger (one-way or two-way door), layers
   touched, docs updated, test added (lesson 3).
5. Merging deploys prod: deploy.yml's `test` job reruns every suite with no credentials, the `deploy`
   job deploys (migrations included) and smoke-tests `/api/health` at the `SiteUrl` output, and the `tag`
   job tags `vX.Y.Z` (lesson 4).
6. Something broke: write a failing test, fix it, then run the retro runbook skill to route the lesson
   into a check, a rule or a runbook (lesson 6).
7. To pause prod, the pause-prod runbook skill runs `gh workflow run deploy.yml --ref main -f stage=prod -f paused=true`
   and keeps the data (lesson 5). Any merge to main resumes prod: re-pause after merging if it should stay paused.

## References

| File | Read when |
|---|---|
| [references/interview.md](references/interview.md) | Step 2, before the first question |
| [references/repo-layout.md](references/repo-layout.md) | P1 and P2 |
| [references/infrastructure.md](references/infrastructure.md) | P3 |
| [references/backend.md](references/backend.md) | P4 |
| [references/database.md](references/database.md) | P5, when the human chose DynamoDB or Postgres |
| [references/frontend.md](references/frontend.md) | P6 |
| [references/ci-cd.md](references/ci-cd.md) | P7 |
| [references/agent-context.md](references/agent-context.md) | P1 and P8: CLAUDE.md, runbook skills, docs, ADRs, PR conventions |
| [references/aws-setup.md](references/aws-setup.md) | Step 5, and when the human asks what the wizard does or a setup step fails |
| [references/lessons-learned.md](references/lessons-learned.md) | Before P3, and whenever a symptom matches one of its entries |