Skip to content

feat(claude): first-touch design-system context - #72

Merged
fredericrous merged 6 commits into
mainfrom
feat/greenrack-entry-hook
Nov 22, 2026
Merged

fredericrous merged 6 commits into
mainfrom
feat/greenrack-entry-hook

Conversation

@fredericrous

Copy link
Copy Markdown
Owner

What

Gives a Claude Code session the design-system index once, when its work first touches a repository that uses the design system, and stops giving the catalog at session start in a folder that holds no repository.

  • dot_claude/tools/greenrack-entry/entry.py: a hook script. It reads the hook event, finds the git root of the touched path (the cwd for Bash), and returns the context once per session, agent and root. A marker claimed with O_CREAT|O_EXCL makes it once even for parallel tool calls; a failure releases the marker so the next call retries, and three failures in a row back off for ten minutes. It always exits 0, and prints nothing or one JSON object for a tool call, or plain text at session start.
  • settings.json.tmpl: the SessionStart entry now runs entry.py --session-start, and a new PreToolUse entry runs it on Read|Edit|Write|MultiEdit|NotebookEdit|Bash. Both call the CLI at ^7.6.0, which prints a short index instead of the 34 KB catalog.
  • .chezmoiignore: the test file stays out of ~/.claude.

The script names no tool of its own: the command, the package names to look for, the label and the per-repository hook paths all arrive as arguments. It is a stopgap until grh has a manifest key for lazy entry (ADR-0075).

The plan is Phase 4 of the one in the design-system repository, which shipped Phases 1 to 3 as release 7.6.0. This branch's pointer plan holds the review record.

Verification

  • 36 tests, standard library only, pass: each tool shape, a subagent call, two parallel runs (one index and one command run), a failing and a hanging command (the whole process group is killed), non-UTF-8 output, trailing junk after the event, a log over 1 MB, and the fast path importing neither json nor re.
  • Three live claude -p sessions started in a parent folder: nothing at start; the first read in a consumer gave the index, the second gave nothing, and a read in a non-consumer gave nothing.
  • The template rendered against the live ~/.claude/settings.json is empty on diff; the template has the same number of directives as before.
  • A call that finds its marker costs 62 ms at the median against 52 ms for an empty Python start (9 ms of its own) on a quiet host. The plan's absolute 60 ms bound at p95 is withdrawn: this machine's interpreter start alone is above it.

Review

Implementation review, backend, lang:python, platform and architect approve after a delta round. Two choices are recorded as deliberate in the pointer plan: the options stay a dict, and the version range is ^7.6.0 rather than ~7.6.0, so the index can list components that later 7.x releases add.

Carried

A hook killed at its 15 s limit between claiming and releasing a marker leaves the root without its index for that session. A denied sibling tool call may drop the context after the marker is claimed. Neither has been seen.

🤖 Generated with Claude Code

fredericrous and others added 6 commits November 21, 2026 21:52
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SessionStart context entry runs entry.py --session-start from the
git root of the cwd, and a PreToolUse entry gives the index once per
session, agent and root on the first touch of a consumer repository. The
script reads the event with the C scanner so a call that finds its
marker does not import json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the hook: output that is not UTF-8 no longer leaves the marker
claimed, a failure reports the command's last stderr line, trailing data
after the event is refused, the failure counter and the log trim are
written safely, and both settings entries pin the CLI floor to 7.6.0 so
an older cached release cannot serve the whole catalog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The push guard names this repository chezmoi; the pointer's code review
line used the plan's name for it, dotfiles. The profiles are the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fredericrous
fredericrous merged commit 6593635 into main Nov 22, 2026
2 checks passed
@fredericrous
fredericrous deleted the feat/greenrack-entry-hook branch November 22, 2026 00:36
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