Skip to content

Map commands + flags + subcommands to categories #11

Description

@aholten

Today _lookup in scripts/annotate-pre.sh keys only on the segment's base command (e.g. git, npm, docker). That loses a lot of signal:

  • git commit vs git push vs git status → all render identically
  • npm install (destructive-ish / network) vs npm test (verify) → same
  • docker run vs docker ps → same
  • rm -rf / vs rm -i file → same danger emoji
  • Shell compound statements (for/while/if/case/do/then/else/done/fi/...) — see PR Replace setup.sh with CLAUDE.md onboarding; fix hook rendering #9; partially implemented, still not right

We want the annotation to reflect what the command is actually doing, not just which binary is invoked.

Scope (to decide on review)

  • Subcommand mapping for high-value tools: git, gh, npm / yarn / pnpm / bun, docker, kubectl, cargo, pip / poetry, make, terraform, aws, gcloud — pick a starting subset
  • Flag-based signal where meaningful: destructive flags (rm -rf, git push --force), dry-run flags (-n, --dry-run), verbose flags, etc.
  • Compound-statement keywords: finish what PR Replace setup.sh with CLAUDE.md onboarding; fix hook rendering #9 started (do/then/else/elif unwrap, for/while/if/case styled, done/fi/esac/in still falling through to gray, function/brace-groups/subshells not handled)

Open questions

  • Where do mappings live? Stay inline in the bash case statement, or move to a data file (e.g. revive command-map.json, which is in-repo but the hook doesn't currently read it)? Data file is more maintainable but adds a parsing step to the hot path. Decide before large expansion.
  • Match precedence. Clearest model: full-command match (Tier 1, e.g. git commit) → base command (Tier 2, e.g. git) → default. The old SKILL.md sketch had this shape but the current hook only has Tier 2.
  • Flags inspection. Full flag parsing per command is a lot of surface. Probably want a small allowlist of "signal flags" per command (--force, --dry-run, -rf) rather than a general parser.

Acceptance

  • git commit, git push, git pull, git rebase render distinctly from generic git status
  • npm install / npm test / npm run <script> render distinctly
  • docker run / docker build / docker compose render distinctly
  • PR Replace setup.sh with CLAUDE.md onboarding; fix hook rendering #9 control-flow TODO is closed: do/then/else/elif unwrap correctly in all tested compound statements, and trailing done/fi/esac no longer fall through to gray (or we have an explicit reason why we let them)
  • All new mappings pass the existing test suite

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