Skip to content

chore: drop the repository's dev-shell session hooks - #291

Draft
kixelated wants to merge 1 commit into
mainfrom
chore/migrate-to-user-dev-shell
Draft

kixelated wants to merge 1 commit into
mainfrom
chore/migrate-to-user-dev-shell

Conversation

@kixelated

Copy link
Copy Markdown
Contributor

Problem

Studio kept the Claude Code and Codex SessionStart dev-shell hooks it inherited from moq, which moq dropped in moq-dev/moq#8183. With a user-level dev-shell loader installed, they get in its way:

  • Claude: .claude/hooks/direnv.sh saves the whole environment at session start (it unsets every inherited variable and re-exports all of them). Claude Code sources it after the user-level hook on every command, so it overrides whatever that loader applied. After a flake or lock change mid-session (such as just upgrade-moq), the loader recaptures, then the saved copy puts back the stale PATH.
  • Claude: the hook runs direnv allow . unconditionally. A checked-out fork branch that only edits flake.nix gets its dev shell evaluated automatically.
  • Codex: .codex/hooks/direnv.sh writes .direnv/codex-env.sh, which nothing reads. .codex/config.toml points BASH_ENV at $HOME/.codex/bash-env.sh, a user-level file. Without that file, bash silently ignores the setting, so contributors without it got no dev shell from the repo either way.

Approach

Delete the hooks and their wiring, as moq did:

  • .claude/hooks/direnv.sh and direnv.test.sh, plus the SessionStart entry in .claude/settings.json (its permissions stay)
  • .codex/hooks.json, .codex/config.toml, and .codex/hooks/direnv.sh
  • their paths in the justfile's shellcheck and shfmt globs, and the test line in just test

CONTRIBUTING.md gets one line: start an agent from a shell that has the dev shell (direnv allow or nix develop), and its commands inherit the pinned tools.

Impact

  • No user-facing change to the studio.
  • Contributors' AI agents no longer get the dev shell from the repository. They inherit it from the shell that starts them, or from a user-level loader.

Alternatives

  • Keep a slimmer Claude hook for contributors without a user-level loader: no automatic direnv allow, export only what the dev shell changes, and skip when a loader is present. Rejected because it keeps a script and its test that the maintainer's setup never runs, while starting the agent from the dev shell already covers that case.
  • Keep the hook but exit early when a user-level loader is present. Rejected because it keeps the automatic approval for everyone else.

Follow-ups

None.

Decisions

  • Maintainer: drop every repository hook rather than keep a slim one.
  • Maintainer: implement directly instead of planning a quest first.
  • Maintainer: add the CONTRIBUTING line.
  • Agent: .gitignore keeps .direnv, which direnv itself still writes.

Validation

  • nix develop --command just ci passes locally: lints, plus 567 tests passed.
  • A fresh headless Claude Code session in this worktree ran only the user-level SessionStart hook. just, cargo, and taplo resolved from the dev shell, and DEV_SHELL_ROOT named this checkout.
  • Before the change, I confirmed in a live session that the repository hook's sidecar was sourced last and determined the command's PATH.

Models

Size: XS
Implementer: Claude Code, claude-opus-5-5, unknown

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

Studio's Claude hook saved the whole environment at session start and was
sourced after any user-level loader, so it put back stale tools after a flake
change and approved every .envrc unconditionally. The Codex hook wrote a
snapshot nothing read, and .codex/config.toml pointed BASH_ENV at a user-level
file. Agents now inherit the dev shell from the shell that starts them, or
from a user-level loader, as moq-dev/moq#8183 did upstream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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