bash.tpl

  1Executes bash commands in persistent shell session with timeout and security measures.
  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. Output Processing: Truncate if exceeds {{ .MaxOutputLength }} characters
 145. Return Result: Include errors, metadata with <cwd></cwd> tags
 15</execution_steps>
 16
 17<usage_notes>
 18- Command required, timeout optional (max 600000ms/10min, default 30min if unspecified)
 19- IMPORTANT: Use Grep/Glob/Agent tools instead of 'find'/'grep'. Use View/LS tools instead of 'cat'/'head'/'tail'/'ls'
 20- Chain with ';' or '&&', avoid newlines except in quoted strings
 21- Shell state persists (env vars, virtual envs, cwd, etc.) unless running in background
 22- Prefer absolute paths over 'cd' (use 'cd' only if user explicitly requests)
 23</usage_notes>
 24
 25<background_execution>
 26- Set background=true to run commands in a separate background shell
 27- Background shells don't share state with the persistent shell
 28- Returns a shell ID for managing the background process
 29- Use bash_output tool to view current output from background shell
 30- Use bash_kill tool to terminate a background shell
 31- Useful for long-running processes, servers, or monitoring tasks
 32</background_execution>
 33
 34<git_commits>
 35When user asks to create git commit:
 36
 371. Single message with three tool_use blocks (IMPORTANT for speed):
 38   - git status (untracked files)
 39   - git diff (staged/unstaged changes)
 40   - git log (recent commit message style)
 41
 422. Add relevant untracked files to staging. Don't commit files already modified at conversation start unless relevant.
 43
 443. Analyze staged changes in <commit_analysis> tags:
 45   - List changed/added files, summarize nature (feature/enhancement/bug fix/refactoring/test/docs)
 46   - Brainstorm purpose/motivation, assess project impact, check for sensitive info
 47   - Don't use tools beyond git context
 48   - Draft concise (1-2 sentences) message focusing on "why" not "what"
 49   - Use clear language, accurate reflection ("add"=new feature, "update"=enhancement, "fix"=bug fix)
 50   - Avoid generic messages, review draft
 51
 524. Create commit with Crush signature using HEREDOC:
 53   git commit -m "$(cat <<'EOF'
 54   Commit message here.
 55{{ if .Attribution.GeneratedWith}}
 56   💘 Generated with Crush
 57{{ end }}
 58{{ if .Attribution.CoAuthoredBy}}
 59   Co-Authored-By: Crush <crush@charm.land>
 60{{ end }}
 61   EOF
 62   )"
 63
 645. If pre-commit hook fails, retry ONCE. If fails again, hook preventing commit. If succeeds but files modified, MUST amend.
 65
 666. Run git status to verify.
 67
 68Notes: 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.
 69</git_commits>
 70
 71<pull_requests>
 72Use gh command for ALL GitHub tasks. When user asks to create PR:
 73
 741. Single message with multiple tool_use blocks (VERY IMPORTANT for speed):
 75   - git status (untracked files)
 76   - git diff (staged/unstaged changes)
 77   - Check if branch tracks remote and is up to date
 78   - git log and 'git diff main...HEAD' (full commit history from main divergence)
 79
 802. Create new branch if needed
 813. Commit changes if needed
 824. Push to remote with -u flag if needed
 83
 845. Analyze changes in <pr_analysis> tags:
 85   - List commits since diverging from main
 86   - Summarize nature of changes
 87   - Brainstorm purpose/motivation
 88   - Assess project impact
 89   - Don't use tools beyond git context
 90   - Check for sensitive information
 91   - Draft concise (1-2 bullet points) PR summary focusing on "why"
 92   - Ensure summary reflects ALL changes since main divergence
 93   - Clear, concise language
 94   - Accurate reflection of changes and purpose
 95   - Avoid generic summaries
 96   - Review draft
 97
 986. Create PR with gh pr create using HEREDOC:
 99   gh pr create --title "title" --body "$(cat <<'EOF'
100
101   ## Summary
102
103   <1-3 bullet points>
104
105   ## Test plan
106
107   [Checklist of TODOs...]
108
109{{ if .Attribution.GeneratedWith}}
110   💘 Generated with Crush
111{{ end }}
112
113   EOF
114   )"
115
116Important:
117
118- Return empty response - user sees gh output
119- Never update git config
120</pull_requests>
121
122<examples>
123Good: pytest /foo/bar/tests
124Bad: cd /foo/bar && pytest tests
125</examples>