-
Treat this file as the single handoff entrypoint.
-
Before any code changes, review open GitHub Issues for the repo and then read:
docs/release-flow.mddocs/milestone-release-checklist.md
-
If instructions conflict, precedence is:
- explicit user instruction in current thread
- this
AGENTS.md - GitHub Issues / GitHub Projects state for the repo
docs/release-flow.mddocs/milestone-release-checklist.md
-
Always update the relevant GitHub Issue(s) before and after implementation batches.
-
Default environment workflow:
- Unless the user explicitly says otherwise, work in local test environment.
- After local verification, deploy to live test/staging for verification.
- For every implementation batch by default: do both local verification and staging deployment verification in the same pass.
- Only promote to production after explicit user approval, using the same verified commit.
-
Branch workflow:
- Use per-issue branches:
issue/<id>-<slug>. - Always branch from
origin/staging, notorigin/main. Creating a branch frommainwill cause merge conflicts when opening a PR tostaging. - Merge issue branches into
stagingfirst. - For normal releases, promote to production only via a direct PR from
stagingintomain(no release branch needed — the branch policy allowsstaging→maindirectly). - Use
hotfix/<slug>only for explicitly approved incidents. - This staging-integration model is the default unless the user explicitly overrides it.
- Use per-issue branches:
-
Worktree branch vs. issue branch:
- When working inside a Claude Code worktree, the session branch is named
claude/<name>— this is the worktree's own bookkeeping branch, not your working branch. - Always create a new
issue/<id>-<slug>branch fromorigin/stagingbefore making any changes:git checkout -b issue/<id>-<slug> origin/staging - Never commit to the
claude/*session branch. All work goes on theissue/<id>-<slug>branch.
- When working inside a Claude Code worktree, the session branch is named
-
Deploy policy:
- Never run
npm run deploy:staging,npm run deploy:prod:main, or any deploy script locally. CI automatically deploys when code merges tostagingormain— you do not need to trigger a deploy. - Local deploy attempts will fail: Cloudflare credentials (
CLOUDFLARE_API_TOKEN,CLOUDFLARE_ACCOUNT_ID) are only available in the CI environment. - If you encounter a Cloudflare authentication error while running a deploy script, stop immediately — you are running a command that belongs in CI, not locally.
- Never run
-
Branch/worktree cleanup routine (default after each completed pass):
- Keep only long-lived branches locally/remotely:
main,staging(unless an active pass needs additional branches). - After merge/deploy, prune refs:
git fetch --prune origin. - Delete merged local branches (except
main/staging):git branch --merged origin/staging | egrep -v '(^\\*|main|staging)' | xargs -n 1 git branch -d(skip if no matches). - Delete remote merged issue/chore/hotfix branches once no longer needed.
- Remove temporary worktrees for completed branches; keep only active worktrees.
- Keep only long-lived branches locally/remotely:
-
Prefer stabilization work (consistency, hardening, tests, UX cleanup) over net-new features unless explicitly requested.
-
Ship in batches: implement, run
npm testandnpm run build, then commit and push. -
Never commit or push directly to
main; always create/use a separate branch for changes and push that branch. -
Use TDD methodology for changes and new features: write/update failing tests first, implement the minimal fix to pass, then refactor with tests green.
-
Keep terminology consistent: use
Simulation,Site,Library,Path, andChannelterms across UI and docs. -
Do not introduce hardcoded UI colors in code; use existing theme variables/tokens. If a new semantic color is truly required, define it in the shared theme system first.
-
Icon accessibility rule: every UI icon must include accessible text. For icon-only controls, require an explicit
aria-labelon the interactive element (and matchingtitlewhere applicable). Decorative inline icons should bearia-hidden="true". -
Any modal/popover that can open on top of another dialog must use
tier="raised"inModalOverlay. -
When catching UI errors, use
getUiErrorMessage()fromsrc/lib/uiError.tsfor consistent messaging. -
Do not leave issue status in an ambiguous state.
-
Default closure policy: once work is verified on shared staging and the user confirms staging sign-off, close the issue (do not wait for production deploy).
-
Do not start newly created or newly requested issues without explicit user confirmation in the current thread.
-
Maintain GitHub Issues in close dialogue with the user: confirm wording/scope before starting newly added user items, and confirm completion criteria before closing them.
-
Batch size policy:
- Default to 3-4 backlog items per pass.
- If scope is stable and low risk, target larger passes (~10 items) to reduce deploy churn.
-
For user-added issues:
- Keep them labeled
pending-discussionuntil discussed. - Do not move them to in-progress automatically.
- Keep them labeled
-
After every merge to
stagingormain, CI auto-deploys via theDeploy LinkSim PagesGitHub Actions workflow. Monitor the workflow run in GitHub Actions and report the commit SHA and build label when the deploy job completes. Do not runnpm run deploy:stagingornpm run deploy:prod:mainmanually after a merge — CI handles it. Manual deploys viaworkflow_dispatchare reserved for overrides only. -
Follow and maintain
docs/release-flow.mdas the source of truth for release promotion steps. -
Follow
docs/release-flow.mdversioning policy (SemVer + explicit bump rules) for all releases. -
Maintain a human-readable
CHANGELOG.mdfor every release; do not use raw commit dumps as release notes. -
Before each production release, verify whether any issues closed since the previous release are missing a milestone and report/fix that metadata drift.
-
Version/channel labeling rule:
- Local must display
vX.Y.Z-alpha+<commit>. - Staging must display
vX.Y.Z-beta+<commit>. - Production must display
vX.Y.Z. - Same commit must use the same base version
X.Y.Zin all environments.
- Local must display
-
Require a SemVer bump before every production release.
-
Deploys must use guarded npm scripts only:
npm run deploy:staging→ https://staging.linksim.linknpm run deploy:staging:preview→ Preview URLnpm run deploy:prod:main→ https://linksim.link
-
Staging deploy default:
- Use
npm run deploy:stagingfromstagingbranch to deploy to https://staging.linksim.link - Do not use preview deploys for normal verification; default is always the shared staging URL.
- Use
-
Never run raw
wrangler pages deployfor release operations. -
If a guarded deploy fails, fix the script/preflight issue and re-run the guarded script. Do not bypass with manual Wrangler deploys.
-
Promotion gate:
- Promote the exact same verified commit from local -> staging -> production.
- If code changes after staging verification, rerun local verification and redeploy staging before production.
- Normal production promotion PR must be
staging->main. - Hotfix promotion PR may be
hotfix/<slug>->mainonly with explicit user approval in-thread.
-
After any hotfix merges to main: immediately create a
chore/sync-main-to-stagingbranch fromorigin/staging, rungit merge origin/main -X ours --no-edit, PR intostaging, merge, and redeploy staging. Do not start new feature work until staging is back in sync. Thedetect-staging-driftworkflow will open a GitHub Issue as a reminder if this is missed. -
Release-reconcile fallback rule: if production promotion cannot be completed via direct
staging->mainand uses ahotfix/*snapshot/reconcile PR instead, the same pass is not complete untilmainis synced back intostaging, staging is redeployed, and the drift issue is closed. -
Local run reliability:
- Restart local server whenever runtime/config/env changes can affect behavior.
- Re-verify affected flows after restart before marking work as done.
-
Production preflight checklist (required before
deploy:prod:main):npm run testnpm run build:bundle- Confirm build label matches intended SemVer channel rules
- Confirm no unresolved issue/project status drift for items in the current pass
- Confirm
CHANGELOG.mdis updated with user-readable highlights for the target release
-
Token-efficient execution:
- Lock scope for each pass before implementation.
- Define done criteria and no-touch areas at pass start.
- Avoid mid-pass feature pivots unless explicitly requested by the user.
-
GitHub Issue workflow:
- Treat GitHub Issues as the canonical backlog for open and completed work.
- Use issue titles as the default source of task naming.
- Prefer one issue per discrete task unless the user explicitly wants a grouped batch.
- Maintain explicit status labels:
pending-discussion->in-progress->in-staging(while open) -> issue closed after staging sign-off ->releasedlabel applied during milestone production release sweep. - After every staging merge/deploy, automatically update the related GitHub Issue(s) label from
in-progresstoin-staging. Do not wait for the user to ask. - Milestone release policy: at production release time, apply
releasedto the milestone's shipped issues (including already-closed staging-verified issues). - Milestone required before closing: always assign a milestone to an issue before closing it as completed. Closing without a milestone triggers an automated workflow that reopens the issue with a warning. Exception: add label
no-milestone-close-okfor approved exceptions (e.g., chore/housekeeping issues that don't belong to a release). - If a historical
docs/BACKLOG.mdfile still exists, treat it as legacy reference only unless the user explicitly asks to maintain it.
- Deploy target policy:
- Always validate live on
https://staging.linksim.link. - Do not use preview URLs unless the user explicitly requests a one-off preview comparison in the current thread.
- Always validate live on
- Per-issue branch policy:
- Start each issue branch from
origin/staging. - Branch name format:
issue/<id>-<slug>. - Keep PR scope to one issue; avoid mixed API/UI/deeplink batches in the same PR.
- Agent safety rails:
- Do not create normal-release
release/*branches. - Do not open PRs to
mainfromissue/*orchore/*branches. - If local branch is behind its PR base branch, rebase/refresh before merging.
- Do not create normal-release
- Start each issue branch from
- Drift check before coding (required):
- Run and report:
git log --oneline origin/staging -5 - Run and report:
git log --oneline origin/main -5 - Run and report:
git cherry -v origin/staging origin/main - If drift exists, create a dedicated
chore/reconcile-...PR before feature work.
- Run and report:
- Verification gates for deep-link/API-affecting work:
npm run test -- --run src/lib/deepLink.test.tsnpm run test -- --run functions/api/v1/calculate.test.tsnpm run test -- --run src/store/appStore.test.tsnpm run build- Manually verify deep-link matrix on staging:
/<simulation>/<simulation>/<site>/<simulation>/<site1>+<site2>/<simulation>/<site1>~<site2>
- Merge and staging deploy sequence per issue:
- Open PR into
stagingand merge. CI auto-deploys to https://staging.linksim.link — do NOT runnpm run deploy:stagingmanually. - After merge, monitor the
Deploy LinkSim Pages / deploy-stagingGitHub Actions job and report the commit SHA and build label from the workflow output when it completes.
- Open PR into
- Milestone promotion model:
- Complete and verify all milestone issues on
stagingfirst. - Promote to production in one batch with a direct PR from
stagingtomain. - Use the exact verified staging commit for production; no code changes between staging sign-off and production deploy.
- Freeze milestone scope at sign-off: no new feature work lands on
staginguntil production deploy completes. - After production deploy, continue new issue work from the updated
origin/stagingbaseline.
- Complete and verify all milestone issues on
- When introducing a new required status check, roll it out in two phases to avoid PR deadlocks:
- merge the workflow that produces the check
- then add that check to branch protection required checks
- Codex 5.3 — use for full implementation passes where quality and breadth of change matter most. Expensive; reserve for when the work warrants it.
- Big Pickle / MiMo V2 Pro Free — good for planning and moderate coding work. Use as the default for most passes.
- Plan mode always — before any implementation pass, always present a plan first. Always recommend which model to use for the next implementation pass.
- Also available but less experienced with this codebase: GPT-Nano, MiniMax M2.5 Free, Nemotron 3 Super Free.
- If this file feels counterintuitive or is missing something, suggestions are welcome — but nothing changes without explicit approval.
- A new agent should be able to continue by being pointed only to this file.
- Do not rely on undocumented tribal knowledge; if a rule is repeated in chat, add it here (or in the linked source-of-truth docs) before ending the pass.