bash.tpl 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. Executes bash commands in persistent shell session with timeout and security measures.
  2. <cross_platform>
  3. Uses mvdan/sh interpreter (Bash-compatible on all platforms including Windows).
  4. Use forward slashes for paths: "ls C:/foo/bar" not "ls C:\foo\bar".
  5. Common shell builtins and core utils available on Windows.
  6. </cross_platform>
  7. <execution_steps>
  8. 1. Directory Verification: If creating directories/files, use LS tool to verify parent exists
  9. 2. Security Check: Banned commands ({{ .BannedCommands }}) return error - explain to user. Safe read-only commands execute without prompts
  10. 3. Command Execution: Execute with proper quoting, capture output
  11. 4. Output Processing: Truncate if exceeds {{ .MaxOutputLength }} characters
  12. 5. Return Result: Include errors, metadata with <cwd></cwd> tags
  13. </execution_steps>
  14. <usage_notes>
  15. - Command required, timeout optional (max 600000ms/10min, default 30min if unspecified)
  16. - IMPORTANT: Use Grep/Glob/Agent tools instead of 'find'/'grep'. Use View/LS tools instead of 'cat'/'head'/'tail'/'ls'
  17. - Chain with ';' or '&&', avoid newlines except in quoted strings
  18. - Shell state persists (env vars, virtual envs, cwd, etc.)
  19. - Prefer absolute paths over 'cd' (use 'cd' only if user explicitly requests)
  20. </usage_notes>
  21. <git_commits>
  22. When user asks to create git commit:
  23. 1. Single message with three tool_use blocks (IMPORTANT for speed):
  24. - git status (untracked files)
  25. - git diff (staged/unstaged changes)
  26. - git log (recent commit message style)
  27. 2. Add relevant untracked files to staging. Don't commit files already modified at conversation start unless relevant.
  28. 3. Analyze staged changes in <commit_analysis> tags:
  29. - List changed/added files, summarize nature (feature/enhancement/bug fix/refactoring/test/docs)
  30. - Brainstorm purpose/motivation, assess project impact, check for sensitive info
  31. - Don't use tools beyond git context
  32. - Draft concise (1-2 sentences) message focusing on "why" not "what"
  33. - Use clear language, accurate reflection ("add"=new feature, "update"=enhancement, "fix"=bug fix)
  34. - Avoid generic messages, review draft
  35. 4. Create commit with Crush signature using HEREDOC:
  36. git commit -m "$(cat <<'EOF'
  37. Commit message here.
  38. {{ if .Attribution.GeneratedWith}}
  39. 💘 Generated with Crush
  40. {{ end }}
  41. {{ if .Attribution.CoAuthoredBy}}
  42. Co-Authored-By: Crush <[email protected]>
  43. {{ end }}
  44. EOF
  45. )"
  46. 5. If pre-commit hook fails, retry ONCE. If fails again, hook preventing commit. If succeeds but files modified, MUST amend.
  47. 6. Run git status to verify.
  48. 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.
  49. </git_commits>
  50. <pull_requests>
  51. Use gh command for ALL GitHub tasks. When user asks to create PR:
  52. 1. Single message with multiple tool_use blocks (VERY IMPORTANT for speed):
  53. - git status (untracked files)
  54. - git diff (staged/unstaged changes)
  55. - Check if branch tracks remote and is up to date
  56. - git log and 'git diff main...HEAD' (full commit history from main divergence)
  57. 2. Create new branch if needed
  58. 3. Commit changes if needed
  59. 4. Push to remote with -u flag if needed
  60. 5. Analyze changes in <pr_analysis> tags:
  61. - List commits since diverging from main
  62. - Summarize nature of changes
  63. - Brainstorm purpose/motivation
  64. - Assess project impact
  65. - Don't use tools beyond git context
  66. - Check for sensitive information
  67. - Draft concise (1-2 bullet points) PR summary focusing on "why"
  68. - Ensure summary reflects ALL changes since main divergence
  69. - Clear, concise language
  70. - Accurate reflection of changes and purpose
  71. - Avoid generic summaries
  72. - Review draft
  73. 6. Create PR with gh pr create using HEREDOC:
  74. gh pr create --title "title" --body "$(cat <<'EOF'
  75. ## Summary
  76. <1-3 bullet points>
  77. ## Test plan
  78. [Checklist of TODOs...]
  79. {{ if .Attribution.GeneratedWith}}
  80. 💘 Generated with Crush
  81. {{ end }}
  82. EOF
  83. )"
  84. Important:
  85. - Return empty response - user sees gh output
  86. - Never update git config
  87. </pull_requests>
  88. <examples>
  89. Good: pytest /foo/bar/tests
  90. Bad: cd /foo/bar && pytest tests
  91. </examples>