setup-llm-optimization
Setup LLM Optimization
What This Sets Up
- SessionStart hook setting
AI_AGENT=1,CLAUDECODE=1, andNODE_OPTIONS=--max-old-space-size=8192 - PreToolUse hook optimizing test commands:
- Strip
--verbose(hard enforcement viaupdatedInputrewrite — wastes tokens) - Suggest
--pool=forks(prevents zombie processes) - Suggest
--bail=1(fail fast, save tokens) - Suggest
--teardownTimeout=5000(prevent hanging teardown) - Suggest
--reporter=githubin CI - Jest: suggest
--bail --forceExit
- Strip
- PostToolUse hook truncating verbose bash output to reduce context bloat
Steps
1. Create hook scripts
Copy scripts/llm-env.sh, scripts/llm-test-flags.sh, and scripts/llm-truncate.sh into .claude/hooks/. Make all executable.
2. Configure hooks in .claude/settings.json
Add to hooks config (merge with existing):
- SessionStart:
.claude/hooks/llm-env.sh - PreToolUse (matcher:
Bash):.claude/hooks/llm-test-flags.sh - PostToolUse (matcher:
Bash):.claude/hooks/llm-truncate.sh
3. Verify
- All hook scripts are executable
-
AI_AGENTandCLAUDECODEare set after session start -
bun test --verboseis silently rewritten tobun test(verbose stripped) -
bun testtriggers suggestions for--pool=forks,--bail=1,--teardownTimeout=5000 -
NODE_OPTIONS=--max-old-space-size=8192is set after session start - Long output is truncated
See REFERENCE.md for vitest config optimizations and test runner tuning.
4. Commit
Stage and commit: Add LLM optimization hooks (env vars, test flags, output truncation)
More from malinskibeniamin/skills
setup-react-rules
Enforce React/TS/security rules via PostToolUse hooks — bans raw HTML, TS escape hatches, XSS vectors, barrel imports, missing passive listeners. Use when enforcing React patterns or component library standards.
9setup-react-compiler
Install React Compiler with rsbuild and enforce compiler-friendly patterns via PostToolUse hooks. Flags manual memoization, derived state, useRef cache. Use when setting up React Compiler or post-compiler patterns.
9setup-biome
Install Biome linter with Ultracite preset, create biome.jsonc config, and configure Claude Code Stop hook for auto-fix before finishing. Use when setting up linting, formatting, Biome, Ultracite, or code quality enforcement.
9setup-quality-gate
Add quality:gate package.json script for fast local/CI quality checks (biome + tsgo + related tests), GitHub Actions workflow, and Stop hook for type checking. Use when setting up quality gates, CI pipelines, or pre-push validation.
9setup-connect-query
Enforce ConnectRPC + Connect Query + Protobuf v2 patterns via PostToolUse hooks. Bans raw useQuery, empty invalidateQueries, $typeName literals. Use when setting up ConnectRPC, protobuf type safety, or data fetching enforcement.
8work-automation-kit
Install planning and project management skills — PRD creation, implementation planning, issue breakdown, bug triage, code review. Use when setting up project planning workflows or creating PRDs.
8