Skip to content

feat: safety hook skills + skill usage telemetry (v0.7.1)#189

Merged
garrytan merged 9 commits intomainfrom
garrytan/safety-hooks-telemetry
Mar 19, 2026
Merged

feat: safety hook skills + skill usage telemetry (v0.7.1)#189
garrytan merged 9 commits intomainfrom
garrytan/safety-hooks-telemetry

Conversation

@garrytan
Copy link
Owner

Summary

  • /careful — on-demand PreToolUse hook that warns before destructive commands (rm -rf, DROP TABLE, force-push, kubectl delete, etc.). User can override. Build artifact cleanups are whitelisted.
  • /freeze — blocks Edit/Write outside a specified directory. Hard deny, not just warning.
  • /guard — meta-skill composing /careful + /freeze into one command.
  • /unfreeze — clears freeze boundary without ending the session.
  • Skill usage telemetry — TemplateContext system bakes per-skill name into preamble JSONL. 18 skills tracked. Hook fire events log pattern name only (no command content for security).
  • Analytics CLIbun run analytics shows top skills, per-repo breakdown, hook fire stats.
  • /retro integration — skills-used-this-week section in weekly retros.

Test Coverage

  • 389 tests pass, 0 failures
  • check-careful.sh: 25 tests (all 8 patterns + safe exceptions + Python fallback + edge cases)
  • check-freeze.sh: 7 tests (boundary enforcement + trailing slash edge case)
  • scripts/analytics.ts: 22 tests (parsing, filtering, formatting, error handling)
  • Telemetry tests: per-skill name correctness in generated output
  • All generated SKILL.md files verified fresh via --dry-run

Pre-Landing Review

No issues found.

Design Review

No frontend files changed — design review skipped.

TODOS

  • On-demand hook skills (/careful, /freeze, /guard) — shipped
  • Skill usage telemetry — shipped

Test plan

  • All tests pass (389 tests, 0 failures)
  • bun run gen:skill-docs --dry-run — all 21 files FRESH
  • bun run skill:check — health dashboard passes
  • bun run analytics — CLI runs successfully

🤖 Generated with Claude Code

garrytan and others added 9 commits March 18, 2026 11:05
Four new on-demand skills using Claude Code's PreToolUse hooks:
- /careful: warns before destructive commands (rm -rf, DROP TABLE, force-push, etc.)
- /freeze: blocks file edits outside a specified directory
- /guard: composes both into one command
- /unfreeze: clears freeze boundary without ending session

Pure bash hook scripts with Python fallback for JSON edge cases.
Safe exceptions for build artifacts (node_modules, dist, .next, etc.).
Hook fire telemetry logs pattern name only (never command content).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TemplateContext system passes skill name through resolver pipeline so
each generated SKILL.md gets its own name baked into the telemetry line.
Appends to ~/.gstack/analytics/skill-usage.jsonl on every invocation.

Covers 14 preamble-using skills + 4 hook skills (inline telemetry).
JSONL format: {"skill":"ship","ts":"...","repo":"my-project"}

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bun run analytics reads ~/.gstack/analytics/skill-usage.jsonl and shows
top skills, per-repo breakdown, hook fire stats, and daily timeline.
Supports --period 7d/30d/all. Handles missing/empty/malformed data.

22 unit tests cover parsing, filtering, formatting, and edge cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Retro Step 2 now reads skill-usage.jsonl and shows which gstack skills
were used during the retro window. Follows the same pattern as the
Greptile signal and Backlog Health metrics — read file, filter by date,
aggregate, present. Skips silently if no analytics data exists.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
32 unit tests for check-careful.sh covering all 8 destructive patterns,
safe exceptions, Python fallback, and malformed input handling.
7 unit tests for check-freeze.sh covering boundary enforcement,
trailing slash edge case, and missing state file.
Telemetry tests verify per-skill name correctness in generated output.
Adds careful/freeze/guard/unfreeze/document-release to ALL_SKILLS.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Safety hook skills and skill usage telemetry shipped.
Analytics CLI and /retro integration included.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merge origin/main which brought /office-hours, /debug, and preamble
Completion Status Protocol. Resolve VERSION (0.7.1) and CHANGELOG
(our entry above 0.7.0). Regenerate all SKILL.md files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add PreToolUse hooks (Edit/Write) to debug/SKILL.md.tmpl that reference
the existing freeze/bin/check-freeze.sh. After Phase 1 investigation,
/debug locks edits to the narrowest affected directory.

Graceful degradation: if freeze script is unavailable, scope lock is
skipped. Users can run /unfreeze to remove the restriction.

Deferred 6 enhancements to TODOS.md, gated on telemetry showing the
freeze hook actually fires in real debugging sessions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merge origin/main which brought proactive skill suggestions, journey-stage
E2E tests, and retro timezone/midnight fixes. Resolve VERSION (0.7.3),
CHANGELOG (our entry above 0.7.2), and gen-skill-docs.ts (keep both
telemetry line and proactive config). Regenerate all 21 SKILL.md files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@garrytan garrytan merged commit c4f679d into main Mar 19, 2026
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