automation-triggers
Skill4 starsChanged 9 months agoMITView on GitHub
Patterns for auto-format on save, auto-lint, auto-test on file change, and CI triggers within Claude Code. Use when the user wants automated reactions to file changes, wants to set up continuous feedback loops, or asks about triggering actions automatically.
- Commits and pushes
In this repository78 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rules/agents.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/claude-initial-setup.mdcCursor rule
- parallel-task-executionSkill
- subagent-patternsSkill
- task-coordinationSkill
- agent-communicationSkill
- context-managementSkill
- multi-agent-orchestrationSkill
- deploy-strategiesSkill
- github-actions-guideSkill
- pipeline-patternsSkill
- anthropic-sdk-guideSkill
- prompt-engineeringSkill
- tool-use-patternsSkill
- automated-review-setupSkill
- pr-standardsSkill
- review-checklistSkill
- file-organizationSkill
- immutability-patternsSkill
- naming-conventionsSkill
- branching-strategySkill
- commit-conventionsSkill
- pr-workflowSkill
- migration-patternsSkill
- query-optimizationSkill
- schema-design-guideSkill
- error-tracingSkill
- log-analysisSkill
- systematic-debuggingSkill
- django-admin-customizationSkill
- django-orm-masterySkill
- drf-api-patternsSkill
- docker-compose-guideSkill
- dockerfile-best-practicesSkill
- multi-stage-buildsSkill
- express-error-handlingSkill
- middleware-patternsSkill
- rest-api-nodeSkill
- async-fastapiSkill
- dependency-injection-fastapiSkill
- pydantic-validationSkill
- concurrency-patterns-goSkill
- error-handling-goSkill
- idiomatic-goSkill
- hook-recipesSkill
- pre-post-hooksSkill
- junit-testingSkill
- maven-gradle-guideSkill
- spring-boot-patternsSkill
- mcp-resource-patternsSkill
- mcp-server-creationSkill
- mcp-tool-designSkill
- context-optimizationSkill
- knowledge-persistenceSkill
- memory-patternsSkill
- caching-strategiesSkill
- lazy-loading-patternsSkill
- profiling-guideSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 7 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 24
Use a PostToolUse hook to format files immediately after modification:
- Distinctive: line 62
Run linters as PostToolUse hooks to surface issues immediately:
- Distinctive: line 86
Run related tests when source files change.
- Distinctive: line 108
Use Stop hooks or git push PreToolUse hooks to integrate with CI:
- Very specific: line 140
Ignoring exit codes: When chaining commands with &&, a failure in formatting stops linting.
- Distinctive: line 142
Auto-testing without test isolation: If tests modify shared state (database, filesystem), auto-running them in hooks can corrupt the …
- Distinctive: line 154
Rule of thumb: If a hook takes > 5 seconds, it should be opt-in, not automatic.
- Distinctive: line 155
Scope narrowly: Always filter by file extension and limit output.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Automation Triggers
Automation triggers create feedback loops that run formatting, linting, testing, or CI actions in response to file changes. They reduce manual intervention and catch issues immediately.
When to Use
- User wants files auto-formatted after every edit
- User asks about auto-linting or auto-testing on save
- User needs continuous feedback during development
- User wants to trigger CI checks or deploy previews automatically
- User mentions "run X every time I change Y"
Core Patterns
Auto-Format on Edit
Use a PostToolUse hook to format files immediately after modification:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"command": "if echo \"$CLAUDE_FILE_PATH\" | grep -qE '\\.(js|ts|jsx|tsx|css|json)$'; then npx prettier --write \"$CLAUDE_FILE_PATH\" 2>/dev/null; fi",
"description": "Auto-format JS/TS/CSS/JSON files with Prettier"
}
]
}
}For Python projects, use Black or Ruff:
{
"matcher": "Edit|Write",
"command": "if echo \"$CLAUDE_FILE_PATH\" | grep -qE '\\.py$'; then ruff format \"$CLAUDE_FILE_PATH\" 2>/dev/null && ruff check --fix \"$CLAUDE_FILE_PATH\" 2>/dev/null; fi",
"description": "Auto-format and fix Python files with Ruff"
}For Go projects:
{
"matcher": "Edit|Write",
"command": "if echo \"$CLAUDE_FILE_PATH\" | grep -qE '\\.go$'; then gofmt -w \"$CLAUDE_FILE_PATH\" && goimports -w \"$CLAUDE_FILE_PATH\" 2>/dev/null; fi",
"description": "Auto-format Go files with gofmt and goimports"
}Auto-Lint After Edit
Run linters as PostToolUse hooks to surface issues immediately:
{
"matcher": "Edit|Write",
"command": "if echo \"$CLAUDE_FILE_PATH\" | grep -qE '\\.(ts|tsx)$'; then npx eslint --no-warn-ignored \"$CLAUDE_FILE_PATH\" 2>&1 | head -30; fi",
"description": "Auto-lint TypeScript files with ESLint"
}Auto Type-Check
For TypeScript, run incremental type-checking after edits:
{
"matcher": "Edit|Write",
"command": "if echo \"$CLAUDE_FILE_PATH\" | grep -qE '\\.tsx?$'; then npx tsc --noEmit --pretty 2>&1 | tail -20; fi",
"description": "Type-check TypeScript after edit"
}Auto-Test on File Change
Run related tests when source files change. Keep the test scope narrow for speed:
{
"matcher": "Edit|Write",
"command": "if echo \"$CLAUDE_FILE_PATH\" | grep -qE '\\.(ts|tsx)$'; then TEST_FILE=$(echo \"$CLAUDE_FILE_PATH\" | sed 's/\\.ts/.test.ts/' | sed 's/\\.tsx/.test.tsx/'); if [ -f \"$TEST_FILE\" ]; then npx vitest run \"$TEST_FILE\" --reporter=verbose 2>&1 | tail -30; fi; fi",
"description": "Run matching test file when source is edited"
}For pytest:
{
"matcher": "Edit|Write",
"command": "if echo \"$CLAUDE_FILE_PATH\" | grep -qE '\\.py$'; then TEST_FILE=$(echo \"$CLAUDE_FILE_PATH\" | sed 's|/\\([^/]*\\)\\.py$|/test_\\1.py|'); if [ -f \"$TEST_FILE\" ]; then python -m pytest \"$TEST_FILE\" -x --tb=short 2>&1 | tail -20; fi; fi",
"description": "Run matching pytest file when Python source is edited"
}CI Trigger Patterns
Use Stop hooks or git push PreToolUse hooks to integrate with CI:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"command": "if echo \"$CLAUDE_TOOL_INPUT\" | grep -q 'git push'; then echo 'Reminder: CI will run on push. Ensure tests pass locally first.'; fi",
"description": "Remind about CI before git push"
}
]
}
}Chaining Multiple Triggers
Combine format + lint + type-check in a single hook with early exit on failure:
{
"matcher": "Edit|Write",
"command": "if echo \"$CLAUDE_FILE_PATH\" | grep -qE '\\.tsx?$'; then npx prettier --write \"$CLAUDE_FILE_PATH\" 2>/dev/null && npx eslint --fix \"$CLAUDE_FILE_PATH\" 2>/dev/null && npx tsc --noEmit --pretty 2>&1 | tail -10; fi",
"description": "Format, lint, and type-check TypeScript files"
}Anti-Patterns
- Running full test suites on every edit: This is too slow. Only run the specific test file related to the changed source file. Full suites belong in CI or explicit user commands.
- Formatting files you did not change: Scope hooks to
$CLAUDE_FILE_PATHonly. Never runprettier --write .in a hook — it reformats the entire project on every edit. - Ignoring exit codes: When chaining commands with
&&, a failure in formatting stops linting. Use;instead of&&if you want all steps to run regardless. - No output truncation: Linter output can be huge. Always pipe through
headortailto limit output and prevent flooding the agent context. - Auto-testing without test isolation: If tests modify shared state (database, filesystem), auto-running them in hooks can corrupt the development environment.
Quick Reference
| Trigger | Tool Matcher | When | Speed Target |
| Format | Edit|Write | PostToolUse | < 1s |
| Lint | Edit|Write | PostToolUse | < 3s |
| Type-check | Edit|Write | PostToolUse | < 5s |
| Test (single) | Edit|Write | PostToolUse | < 10s |
| CI reminder | Bash (git push) | PreToolUse | instant |
Rule of thumb: If a hook takes > 5 seconds, it should be opt-in, not automatic. Scope narrowly: Always filter by file extension and limit output.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

