Skip to content

DRY up git permission rules: chezmoi-template one verb list across git / git -C / rtk git / chezmoi git #32

Description

@nickvigilante

Problem

home/dot_claude/settings.json hand-maintains git permission rules separately for several invocation prefixes, and they've already drifted:

  • bare git …Bash(git log *), Bash(git diff *), … plus the narrowed tag -l/remote -v/reflog show read forms.
  • git -C * … — only a partial mirror (a subset of the verbs is duplicated).
  • rtk git … — the rtk Bash hook rewrites git Xrtk git X, so deny rules must be mirrored under this prefix (see Harden distill skill, audit permission allowlist, track rtk hook #26).
  • chezmoi git … — chezmoi's git passthrough; currently not covered at all.

Same story for the deny list (branch -d / -D / --delete), which today only mirrors git and rtk git.

Maintaining these by hand means every new allowed/denied git verb has to be added in up to four places — and the prefixes are already out of sync (git -C * partial, chezmoi git missing).

Proposal

Make settings.json a chezmoi template (settings.json.tmpl) and generate the git rules from a single source of truth:

  • one list of read-only allow verbs: log *, diff *, show *, status *, blame *, tag -l*, tag, remote -v, remote show *, remote get-url *, ls-files *, stash list *, rev-parse *, describe *, worktree list *, for-each-ref *, shortlog *, reflog show *, reflog
  • one list of deny verbs: branch -d *, branch -D *, branch --delete *
  • one list of providers/prefixes: git, git -C *, rtk git, chezmoi git

A template loop then emits the cross-product as Bash(<provider> <verb>) into the allow / deny arrays. Adding a verb or a provider becomes a one-line change that fans out everywhere, in sync.

Notes / acceptance

  • Only the git block is generated; the rest of settings.json (kubectl/helm entries, hooks, non-git tools) stays literal in the template.
  • Emit valid JSON — handle trailing commas (build the list and toJson it, or guard the last element).
  • Add a render check (a run_onchange_ step or dotfiles doctor assertion) that chezmoi cat ~/.claude/settings.json | jq . parses — a template bug must not silently break all permissions.
  • Keep the rtk-rewrite invariant: the hook rewrites git …rtk git …, so the rtk git deny mirror must remain (that's why branch-delete is denied under both prefixes — see Harden distill skill, audit permission allowlist, track rtk hook #26).
  • Decide whether git -C * should compose with rtk/chezmoi (probably unnecessary — git -C is bare-git only).

Why now

Surfaced while hardening the permission allowlist in #26, where the rtk git deny mirrors were added by hand — exactly the maintenance burden this would remove.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions