$npx -y skills add girijashankarj/cursor-handbook --skill automation-helperDesign and create automation workflows — shell scripts, Cursor hooks, GitHub Actions, cron jobs, and task runners. Use when the user asks to automate a process, create a script, or set up a workflow.
| 1 | # Skill: Automation Helper |
| 2 | |
| 3 | Design and implement automation workflows for repetitive development tasks using shell scripts, Cursor hooks, GitHub Actions, or task runners. |
| 4 | |
| 5 | ## Trigger |
| 6 | When the user asks to automate a process, create a shell script, set up a GitHub Action, add a Cursor hook, or streamline a repetitive workflow. |
| 7 | |
| 8 | ## Prerequisites |
| 9 | - [ ] Clear understanding of the task to automate |
| 10 | - [ ] Target platform identified (local, CI, Cursor hook, cron) |
| 11 | |
| 12 | ## Steps |
| 13 | |
| 14 | ### Step 1: Identify Automation Type |
| 15 | |
| 16 | | Type | Tool | Best For | |
| 17 | |------|------|----------| |
| 18 | | **Pre-commit check** | Cursor hook / husky | Lint, format, type-check before commit | |
| 19 | | **CI pipeline step** | GitHub Actions / GitLab CI | Build, test, deploy on push/PR | |
| 20 | | **Local task** | Shell script / Makefile | Dev environment setup, data seeding | |
| 21 | | **Scheduled job** | Cron / CloudWatch Events | Report generation, cleanup, backups | |
| 22 | | **IDE automation** | Cursor hook | Auto-format, auto-test, notifications | |
| 23 | | **Workflow orchestration** | GitHub Actions / scripts | Multi-step release, dependency updates | |
| 24 | |
| 25 | ### Step 2: Gather Requirements |
| 26 | - [ ] What triggers the automation? (manual, git event, schedule, file change) |
| 27 | - [ ] What inputs does it need? (files, env vars, user input) |
| 28 | - [ ] What does it produce? (files, logs, notifications, side effects) |
| 29 | - [ ] What are the failure modes? (missing deps, network errors, permissions) |
| 30 | - [ ] Should it be idempotent? (safe to re-run) |
| 31 | |
| 32 | ### Step 3: Design the Workflow |
| 33 | - [ ] Break into discrete steps (each step should do one thing) |
| 34 | - [ ] Identify dependencies between steps |
| 35 | - [ ] Define success/failure criteria for each step |
| 36 | - [ ] Plan error handling and rollback |
| 37 | - [ ] Determine logging and notification needs |
| 38 | |
| 39 | ### Step 4: Implement |
| 40 | |
| 41 | #### Shell Script Template |
| 42 | ```bash |
| 43 | #!/usr/bin/env bash |
| 44 | set -euo pipefail |
| 45 | |
| 46 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 47 | PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 48 | |
| 49 | log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"; } |
| 50 | error() { log "ERROR: $*" >&2; exit 1; } |
| 51 | |
| 52 | # Validate prerequisites |
| 53 | command -v node >/dev/null 2>&1 || error "node is required" |
| 54 | |
| 55 | log "Starting [task name]..." |
| 56 | |
| 57 | # Step 1: [description] |
| 58 | log "Step 1: [description]" |
| 59 | # implementation here |
| 60 | |
| 61 | # Step 2: [description] |
| 62 | log "Step 2: [description]" |
| 63 | # implementation here |
| 64 | |
| 65 | log "Done." |
| 66 | ``` |
| 67 | |
| 68 | #### GitHub Actions Template |
| 69 | ```yaml |
| 70 | name: [Workflow Name] |
| 71 | on: |
| 72 | [trigger]: |
| 73 | branches: [main] |
| 74 | paths: |
| 75 | - 'src/**' |
| 76 | |
| 77 | jobs: |
| 78 | [job-name]: |
| 79 | runs-on: ubuntu-latest |
| 80 | steps: |
| 81 | - uses: actions/checkout@v4 |
| 82 | - uses: actions/setup-node@v4 |
| 83 | with: |
| 84 | node-version: '20' |
| 85 | cache: 'npm' |
| 86 | - run: npm ci |
| 87 | - run: [command] |
| 88 | ``` |
| 89 | |
| 90 | #### Cursor Hook Template (`.cursor/hooks/`) |
| 91 | ```bash |
| 92 | #!/usr/bin/env bash |
| 93 | set -euo pipefail |
| 94 | |
| 95 | # Hook: [name] |
| 96 | # Trigger: [when this runs] |
| 97 | # Purpose: [what it does] |
| 98 | |
| 99 | [implementation] |
| 100 | ``` |
| 101 | |
| 102 | #### Makefile Template |
| 103 | ```makefile |
| 104 | .PHONY: [target] |
| 105 | |
| 106 | [target]: ## [description] |
| 107 | @echo "Running [target]..." |
| 108 | [command] |
| 109 | ``` |
| 110 | |
| 111 | ### Step 5: Add Error Handling |
| 112 | - [ ] Use `set -euo pipefail` in all bash scripts |
| 113 | - [ ] Add meaningful error messages with context |
| 114 | - [ ] Implement cleanup on failure (trap EXIT) |
| 115 | - [ ] Add retry logic for transient failures (network, rate limits) |
| 116 | - [ ] Log failures with enough context to debug |
| 117 | |
| 118 | ```bash |
| 119 | cleanup() { |
| 120 | local exit_code=$? |
| 121 | if [ $exit_code -ne 0 ]; then |
| 122 | log "Script failed with exit code $exit_code" |
| 123 | # cleanup actions here |
| 124 | fi |
| 125 | } |
| 126 | trap cleanup EXIT |
| 127 | ``` |
| 128 | |
| 129 | ### Step 6: Add Documentation |
| 130 | - [ ] Header comment with purpose, trigger, prerequisites |
| 131 | - [ ] Usage examples in the script or README |
| 132 | - [ ] Document required environment variables |
| 133 | - [ ] Document expected inputs and outputs |
| 134 | |
| 135 | ### Step 7: Test the Automation |
| 136 | - [ ] Run manually with expected inputs |
| 137 | - [ ] Test failure scenarios (missing inputs, network errors) |
| 138 | - [ ] Test idempotency (run twice — same result) |
| 139 | - [ ] Verify logging output is useful |
| 140 | - [ ] Verify no secrets are logged or exposed |
| 141 | |
| 142 | ### Step 8: Wire Up the Trigger |
| 143 | - [ ] For hooks: add to `.cursor/hooks.json` |
| 144 | - [ ] For CI: add to `.github/workflows/` or `.gitlab-ci.yml` |
| 145 | - [ ] For cron: add crontab entry or CloudWatch rule |
| 146 | - [ ] For manual: add to `Makefile` or `package.json` scripts |
| 147 | |
| 148 | ## Rules |
| 149 | - **ALWAYS** use `set -euo pipefail` in bash scripts |
| 150 | - **ALWAYS** validate inputs and prerequisites before executing |
| 151 | - **NEVER** hardcode secrets — use environment variables |
| 152 | - **NEVER** use `rm -rf /` or other dangerous commands without safeguards |
| 153 | - **ALWAYS** add a `--dry-run` option for destructive operations |
| 154 | - Scripts must be idempotent unless explicitly documented otherwise |
| 155 | - Prefer `#!/usr/bin/env bash` over `#!/bin/bash` for portability |
| 156 | |
| 157 | ## Common Automations |
| 158 | |
| 159 | | Automation | Implementation | |
| 160 | |-----------|---------------| |
| 161 | | |