Skip to content

Zach's Worktree Agent Experience Improvement Playground#630

Draft
zachlatta wants to merge 5 commits into
mainfrom
improved-agent-experience
Draft

Zach's Worktree Agent Experience Improvement Playground#630
zachlatta wants to merge 5 commits into
mainfrom
improved-agent-experience

Conversation

@zachlatta

Copy link
Copy Markdown
Member

This is a playground PR for me to play around with trying to get the agent experience for working with Stardance to be much nicer.

zachlatta and others added 4 commits June 17, 2026 17:39
Capture host-specific gotchas not in the README: untracked
docker-compose.override.yml, arm64 bundle-install exit-7 fix via
linux/amd64, pg16→pg18 mismatch + PGDATA, lean --exclude-table-data
mirror, worktree .env sourcing from parent repo, dev-login route,
Tailscale RAILS_DEVELOPMENT_HOSTS, and first-boot timing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
bin/setup never copied .env or installed JS deps, so a fresh checkout
booted with no node_modules and (on the host) no .env at all. Add both:

- copy example.env -> .env when missing (its dev keys work as-is)
- install JS deps via Corepack (package.json pins yarn@4; a plain global
  yarn is usually v1 and refuses to install against the packageManager pin)

Also document the non-docker gotchas in the README: yarn-4-via-corepack,
the DATABASE_URL `db` hostname only resolving inside docker (use localhost
on the host), and the PORT override when 3000 is already taken.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Each git worktree now gets its own non-colliding dev environment so multiple
worktrees (and the agents working in them) can run side by side.

- bin/worktree-env.sh: derive deterministic web (3000+) and db (5432+) ports
  from the worktree name, with free-port fallback; reuse an existing db
  container's host port so DATABASE_URL never drifts.
- docker-compose.yml: parameterize db/web host ports (${DB_PORT}/${WEB_PORT})
  so each worktree's own compose-project db can run simultaneously (previously
  all worktrees collided on 5432:5432). The web service is now self-contained
  (its own DATABASE_URL/PORT) so the native localhost URL doesn't break it.
- bin/dev / bin/setup: re-exec under `mise exec ruby@.. node@..` since recent
  mise no longer auto-activates from .ruby-version; bring up the worktree's db
  and point .env's DATABASE_URL at localhost:$DB_PORT automatically.
- .node-version: pin node 22 for the toolchain re-exec.
- .gitignore: ignore docker-compose.override.yml and the Playwright scratch dir.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Investigated recent agent sessions on this repo (via the pdw warehouse) and
fixed the two most-repeated sources of friction:

- Bare `bin/rails`/`bin/bundle`/etc. from a fresh shell ran on the macOS system
  Ruby 2.6 and died with "`windows` is not a valid platform", because recent
  mise doesn't auto-activate from .ruby-version and only bin/dev/bin/setup had
  the re-exec guard. Extract that guard into bin/toolchain.rb and require it from
  bin/rails, bin/rake, bin/bundle, bin/rubocop, bin/brakeman (and the bash form
  in bin/lint), so they auto-select the pinned Ruby/Node. Guarded to run once and
  only when mise is present, so CI/Docker/non-mise contributors fall through.

- config/initializers/git_version.rb shelled out to git on every boot; inside
  Docker the worktree .git pointer can't resolve and git's "fatal: not a git
  repository" leaked to stderr before the rescue, spamming every rails/test run.
  Redirect git stderr to /dev/null and fall back to "unknown" on empty output.

Also refresh AGENTS.md to document the self-healing binstubs and the remaining
bare-binary traps (yarn -> corepack yarn, psql -> docker compose exec db psql).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zachlatta zachlatta marked this pull request as draft June 19, 2026 14:35
Add a step-by-step PR workflow to AGENTS.md (mirrored to CLAUDE.md): merge
latest main first, run a code-quality review, run CI locally, push only the
main↔feature diff via `rebase --onto` (excluding the tooling), and let the
human write the PR body from the repo template.

Add bin/ci-local mirroring .github/workflows/ci.yml so the "run CI locally"
step is turnkey and stays in sync with the repo's own CI definition.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant