Automating Repetition — Skills, Hooks, and Workflows
Every Repetitive Task Is a Productivity Leak
Watch yourself work for a day and count how many times you do the same thing. Run the linter before committing. Write the same PR description format. Format code after generating it. Check that imports are sorted. Run the same test command with the same flags. Each occurrence takes 30 seconds to 2 minutes. Across a day, these leaks add up to 30-60 minutes of pure overhead.
The 5.7x approach has a simple rule: automate on the third occurrence. The first time you do something manually, fine. The second time, note it. The third time, automate it. Once automated, it never costs time again.
Claude Code provides three automation layers: skills for complex recurring workflows, hooks for automatic quality gates, and custom commands for project-specific shortcuts.
Skills: Reusable Workflow Templates
Skills are markdown files that describe how to perform a specific task. Claude Code reads them automatically when they are relevant, giving AI the knowledge to execute complex workflows consistently.
Create skills in your project's .claude/skills/ directory:
<!-- .claude/skills/deploy.md -->
# Deployment Skill
When asked to deploy, follow these steps:
1. Run the test suite: `npm test`
2. If tests fail, fix the issues before continuing
3. Run the linter: `npm run lint`
4. Build the project: `npm run build`
5. If build succeeds, commit any pending changes
6. Push to the main branch: `git push origin main`
7. Verify the Vercel deployment started by checking git status
8. Report the deployment URL
Now when you say "deploy," Claude Code follows the exact process every time:
claude "deploy"
# Claude reads the skill and executes all 8 steps automatically
More Skill Examples
Code review skill:
<!-- .claude/skills/review.md -->
# Code Review Skill
When asked to review code or a PR:
1. Read all changed files using `git diff`
2. Check for:
- Type safety issues
- Missing error handling
- Inconsistent naming conventions
- Missing tests for new functionality
- Security concerns (exposed secrets, SQL injection, XSS)
- Performance issues (N+1 queries, unnecessary re-renders)
3. Organize findings by severity: critical, warning, suggestion
4. Provide specific line references and fix suggestions
New lesson skill:
<!-- .claude/skills/new-lesson.md -->
# New Lesson Skill
When creating a new course lesson:
1. Check existing lessons in the course directory for numbering
2. Create both .en.mdx and .es.mdx files
3. Include frontmatter: title, description, date, tags, category, order, course
4. Structure content with ## for main sections, ### for subsections
5. Target 800-1200 words per lesson
6. Include code examples where relevant
7. Ensure Spanish version is a full translation, not a summary
Hooks: Automatic Quality Gates
Hooks run automatically when specific events happen in Claude Code. They are your automated quality enforcement layer.
Pre-Commit Hooks
Set up hooks that run before every commit to catch issues automatically:
// .claude/hooks.json
{
"pre-commit": [
{
"command": "npm run lint",
"description": "Run linter before committing"
},
{
"command": "npm run typecheck",
"description": "Verify TypeScript types"
},
{
"command": "npm test -- --changed",
"description": "Run tests on changed files"
}
]
}
With these hooks in place, every commit automatically passes through linting, type checking, and testing. No manual step required, no chance of forgetting.
Post-Write Hooks
Hooks can also run after AI writes or modifies files:
{
"post-write": [
{
"pattern": "*.tsx",
"command": "npx prettier --write",
"description": "Auto-format React components after changes"
},
{
"pattern": "*.css",
"command": "npx prettier --write",
"description": "Auto-format CSS after changes"
}
]
}
This means every file AI creates is automatically formatted. You never need to think about formatting again.
Custom Commands for Project-Specific Shortcuts
Beyond skills and hooks, create custom slash commands for tasks specific to your project:
<!-- .claude/commands/new-course.md -->
# /new-course
Create a new course with the following structure:
Arguments: $COURSE_NAME, $LESSON_COUNT
1. Create directory: src/content/courses/$COURSE_NAME/
2. Create _meta.en.mdx and _meta.es.mdx with course metadata
3. Create $LESSON_COUNT lesson files (both .en.mdx and .es.mdx)
4. Each lesson file should have proper frontmatter with sequential ordering
5. Generate initial content outlines for each lesson
Usage:
claude "/new-course ai-security 10"
# Creates the entire course structure with 22 files
Real Example: The /deploy Workflow
Here is how a complete deployment automation works in practice:
# Before automation: manual deployment checklist
# 1. Remember to run tests (sometimes forget)
# 2. Remember to lint (often skip)
# 3. Remember to build locally (catch errors late)
# 4. Manually commit with a message
# 5. Push to main
# 6. Check Vercel dashboard for deployment status
# 7. Test the production URL
# Total time: 8-12 minutes, error-prone
# After automation: one command
claude "deploy the current changes"
# Claude reads the deploy skill and executes every step
# Total time: 3-4 minutes, no steps skipped
Time saved per deployment: 5-8 minutes. If you deploy 3-4 times per day, that is 15-32 minutes saved daily. Over a month, that is 5-10 hours recovered from a single automation.
The "Automate on the Third Occurrence" Rule
Here is the practical process:
- First occurrence: Do the task manually. Notice the steps involved.
- Second occurrence: Do it manually again. Write down the steps this time.
- Third occurrence: Before doing it, create a skill, hook, or command. Then use the automation.
This rule prevents two failure modes:
- Premature automation: Automating something you do once wastes more time than it saves.
- Chronic manual work: Doing the same thing 50 times manually when 5 minutes of setup would have automated it.
Common tasks that hit the third occurrence quickly:
| Task | Automation Type | Setup Time | Time Saved Per Use | |------|----------------|------------|-------------------| | Pre-commit checks | Hook | 5 minutes | 2-3 minutes | | Code formatting | Post-write hook | 3 minutes | 30 seconds | | PR creation | Skill | 10 minutes | 5-8 minutes | | Course scaffolding | Custom command | 15 minutes | 20-30 minutes | | Deployment | Skill | 10 minutes | 5-8 minutes | | Code review | Skill | 10 minutes | 15-20 minutes |
Building a Personal Automation Library
Over time, your collection of skills, hooks, and commands becomes a personal automation library. This library is a major competitive advantage -- it means every project you start benefits from every automation you have ever built.
Structure your automation library:
.claude/
skills/
deploy.md # Deployment workflow
review.md # Code review process
new-lesson.md # Content creation
refactor.md # Safe refactoring steps
debug.md # Systematic debugging
hooks.json # Automatic quality gates
commands/
new-course.md # Course scaffolding
new-component.md # Component creation
new-api-route.md # API route scaffolding
Tips for maintaining your library:
- Keep skills focused on one task each
- Update skills when your process changes
- Share useful skills across projects via a template repository
- Document the "why" in your skills, not just the "what"
Measuring Time Saved
Track the impact of your automations to justify the investment and identify what to automate next:
## Automation Log
### Week of March 24, 2026
- deploy skill: used 12 times, saved ~72 minutes
- review skill: used 5 times, saved ~75 minutes
- pre-commit hooks: triggered 28 times, caught 4 issues early
- format hooks: triggered ~200 times, estimated 60 minutes saved
Total time saved this week: ~3.5 hours
Total setup time invested: ~1 hour (cumulative)
ROI: 3.5x return in the first week alone
The ROI on automation is almost always positive by the second week. By the second month, the cumulative hours saved are significant. And unlike manual work, automations continue saving time indefinitely once created.
This is the 5.7x principle applied to your own workflow: instead of manually executing repetitive tasks, describe them once in a skill or hook and let automation handle them forever. The time you invest in automation compounds into a permanent productivity increase.