Executes bash commands in persistent shell session with timeout and security measures.
Uses mvdan/sh interpreter (Bash-compatible on all platforms including Windows).
Use forward slashes for paths: "ls C:/foo/bar" not "ls C:\foo\bar".
Common shell builtins and core utils available on Windows.
1. Directory Verification: If creating directories/files, use LS tool to verify parent exists
2. Security Check: Banned commands ({{ .BannedCommands }}) return error - explain to user. Safe read-only commands execute without prompts
3. Command Execution: Execute with proper quoting, capture output
4. Output Processing: Truncate if exceeds {{ .MaxOutputLength }} characters
5. Return Result: Include errors, metadata with tags
- Command required, timeout optional (max 600000ms/10min, default 30min if unspecified)
- IMPORTANT: Use Grep/Glob/Agent tools instead of 'find'/'grep'. Use View/LS tools instead of 'cat'/'head'/'tail'/'ls'
- Chain with ';' or '&&', avoid newlines except in quoted strings
- Shell state persists (env vars, virtual envs, cwd, etc.) unless running in background
- Prefer absolute paths over 'cd' (use 'cd' only if user explicitly requests)
- Set background=true to run commands in a separate background shell
- Background shells don't share state with the persistent shell
- Returns a shell ID for managing the background process
- Use bash_output tool to view current output from background shell
- Use bash_kill tool to terminate a background shell
- Useful for long-running processes, servers, or monitoring tasks
When user asks to create git commit:
1. Single message with three tool_use blocks (IMPORTANT for speed):
- git status (untracked files)
- git diff (staged/unstaged changes)
- git log (recent commit message style)
2. Add relevant untracked files to staging. Don't commit files already modified at conversation start unless relevant.
3. Analyze staged changes in tags:
- List changed/added files, summarize nature (feature/enhancement/bug fix/refactoring/test/docs)
- Brainstorm purpose/motivation, assess project impact, check for sensitive info
- Don't use tools beyond git context
- Draft concise (1-2 sentences) message focusing on "why" not "what"
- Use clear language, accurate reflection ("add"=new feature, "update"=enhancement, "fix"=bug fix)
- Avoid generic messages, review draft
4. Create commit with Crush signature using HEREDOC:
git commit -m "$(cat <<'EOF'
Commit message here.
{{ if .Attribution.GeneratedWith}}
💘 Generated with Crush
{{ end }}
{{ if .Attribution.CoAuthoredBy}}
Co-Authored-By: Crush
{{ end }}
EOF
)"
5. If pre-commit hook fails, retry ONCE. If fails again, hook preventing commit. If succeeds but files modified, MUST amend.
6. Run git status to verify.
Notes: 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.
Use gh command for ALL GitHub tasks. When user asks to create PR:
1. Single message with multiple tool_use blocks (VERY IMPORTANT for speed):
- git status (untracked files)
- git diff (staged/unstaged changes)
- Check if branch tracks remote and is up to date
- git log and 'git diff main...HEAD' (full commit history from main divergence)
2. Create new branch if needed
3. Commit changes if needed
4. Push to remote with -u flag if needed
5. Analyze changes in tags:
- List commits since diverging from main
- Summarize nature of changes
- Brainstorm purpose/motivation
- Assess project impact
- Don't use tools beyond git context
- Check for sensitive information
- Draft concise (1-2 bullet points) PR summary focusing on "why"
- Ensure summary reflects ALL changes since main divergence
- Clear, concise language
- Accurate reflection of changes and purpose
- Avoid generic summaries
- Review draft
6. Create PR with gh pr create using HEREDOC:
gh pr create --title "title" --body "$(cat <<'EOF'
## Summary
<1-3 bullet points>
## Test plan
[Checklist of TODOs...]
{{ if .Attribution.GeneratedWith}}
💘 Generated with Crush
{{ end }}
EOF
)"
Important:
- Return empty response - user sees gh output
- Never update git config
Good: pytest /foo/bar/tests
Bad: cd /foo/bar && pytest tests