bash.tpl

  1Executes bash commands with automatic background conversion for long-running tasks.
  2
  3<cross_platform>
  4Uses mvdan/sh interpreter (Bash-compatible on all platforms including Windows).
  5Use forward slashes for paths: "ls C:/foo/bar" not "ls C:\foo\bar".
  6Common shell builtins and core utils available on Windows.
  7</cross_platform>
  8
  9<execution_steps>
 101. Directory Verification: If creating directories/files, use LS tool to verify parent exists
 112. Security Check: Banned commands ({{ .BannedCommands }}) return error - explain to user. Safe read-only commands execute without prompts
 123. Command Execution: Execute with proper quoting, capture output
 134. Auto-Background: Commands exceeding 1 minute automatically move to background and return shell ID
 145. Output Processing: Truncate if exceeds {{ .MaxOutputLength }} characters
 156. Return Result: Include errors, metadata with <cwd></cwd> tags
 16</execution_steps>
 17
 18<usage_notes>
 19- Command required, working_dir optional (defaults to current directory)
 20- IMPORTANT: Use Grep/Glob/Agent tools instead of 'find'/'grep'. Use View/LS tools instead of 'cat'/'head'/'tail'/'ls'
 21- Chain with ';' or '&&', avoid newlines except in quoted strings
 22- Each command runs in independent shell (no state persistence between calls)
 23- Prefer absolute paths over 'cd' (use 'cd' only if user explicitly requests)
 24</usage_notes>
 25
 26<background_execution>
 27- Set run_in_background=true to run commands in a separate background shell
 28- Returns a shell ID for managing the background process
 29- Use job_output tool to view current output from background shell
 30- Use job_kill tool to terminate a background shell
 31- IMPORTANT: NEVER use `&` at the end of commands to run in background - use run_in_background parameter instead
 32- Commands that should run in background:
 33  * Long-running servers (e.g., `npm start`, `python -m http.server`, `node server.js`)
 34  * Watch/monitoring tasks (e.g., `npm run watch`, `tail -f logfile`)
 35  * Continuous processes that don't exit on their own
 36  * Any command expected to run indefinitely
 37- Commands that should NOT run in background:
 38  * Build commands (e.g., `npm run build`, `go build`)
 39  * Test suites (e.g., `npm test`, `pytest`)
 40  * Git operations
 41  * File operations
 42  * Short-lived scripts
 43</background_execution>
 44
 45<git_commits>
 46When user asks to create git commit:
 47
 481. Single message with three tool_use blocks (IMPORTANT for speed):
 49   - git status (untracked files)
 50   - git diff (staged/unstaged changes)
 51   - git log (recent commit message style)
 52
 532. Add relevant untracked files to staging. Don't commit files already modified at conversation start unless relevant.
 54
 553. Analyze staged changes in <commit_analysis> tags:
 56   - List changed/added files, summarize nature (feature/enhancement/bug fix/refactoring/test/docs)
 57   - Brainstorm purpose/motivation, assess project impact, check for sensitive info
 58   - Don't use tools beyond git context
 59   - Draft concise (1-2 sentences) message focusing on "why" not "what"
 60   - Use clear language, accurate reflection ("add"=new feature, "update"=enhancement, "fix"=bug fix)
 61   - Avoid generic messages, review draft
 62
 634. Create commit{{ if or (eq .Attribution.TrailerStyle "assisted-by") (eq .Attribution.TrailerStyle "co-authored-by")}} with attribution{{ end }} using HEREDOC:
 64   git commit -m "$(cat <<'EOF'
 65   Commit message here.
 66
 67{{ if .Attribution.GeneratedWith }}
 68   💘 Generated with Crush
 69{{ end}}
 70{{if eq .Attribution.TrailerStyle "assisted-by" }}
 71
 72   Assisted-by: {{ .ModelName }} via Crush <crush@charm.land>
 73{{ else if eq .Attribution.TrailerStyle "co-authored-by" }}
 74
 75   Co-Authored-By: Crush <crush@charm.land>
 76{{ end }}
 77
 78   EOF
 79   )"
 80
 815. If pre-commit hook fails, retry ONCE. If fails again, hook preventing commit. If succeeds but files modified, MUST amend.
 82
 836. Run git status to verify.
 84
 85Notes: Use "git commit -am" when possible, don't stage unrelated files, NEVER update config, don't push, no -i flags, no empty commits, return empty response.
 86</git_commits>
 87
 88<pull_requests>
 89Use gh command for ALL GitHub tasks. When user asks to create PR:
 90
 911. Single message with multiple tool_use blocks (VERY IMPORTANT for speed):
 92   - git status (untracked files)
 93   - git diff (staged/unstaged changes)
 94   - Check if branch tracks remote and is up to date
 95   - git log and 'git diff main...HEAD' (full commit history from main divergence)
 96
 972. Create new branch if needed
 983. Commit changes if needed
 994. Push to remote with -u flag if needed
100
1015. Analyze changes in <pr_analysis> tags:
102   - List commits since diverging from main
103   - Summarize nature of changes
104   - Brainstorm purpose/motivation
105   - Assess project impact
106   - Don't use tools beyond git context
107   - Check for sensitive information
108   - Draft concise (1-2 bullet points) PR summary focusing on "why"
109   - Ensure summary reflects ALL changes since main divergence
110   - Clear, concise language
111   - Accurate reflection of changes and purpose
112   - Avoid generic summaries
113   - Review draft
114
1156. Create PR with gh pr create using HEREDOC:
116   gh pr create --title "title" --body "$(cat <<'EOF'
117
118   ## Summary
119
120   <1-3 bullet points>
121
122   ## Test plan
123
124   [Checklist of TODOs...]
125
126{{ if .Attribution.GeneratedWith}}
127   💘 Generated with Crush
128{{ end }}
129
130   EOF
131   )"
132
133Important:
134
135- Return empty response - user sees gh output
136- Never update git config
137</pull_requests>
138
139<examples>
140Good: pytest /foo/bar/tests
141Bad: cd /foo/bar && pytest tests
142</examples>