1Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures.
  2
  3CROSS-PLATFORM SHELL SUPPORT:
  4
  5- This tool uses a shell interpreter (mvdan/sh) that mimics the Bash language,
  6  so you should use Bash syntax in all platforms, including Windows.
  7  The most common shell builtins and core utils are available in Windows as
  8  well.
  9- Make sure to use forward slashes (/) as path separators in commands, even on
 10  Windows. Example: "ls C:/foo/bar" instead of "ls C:\foo\bar".
 11
 12Before executing the command, please follow these steps:
 13
 141. Directory Verification:
 15
 16- If the command will create new directories or files, first use the LS tool to verify the parent directory exists and is the correct location
 17- For example, before running "mkdir foo/bar", first use LS to check that "foo" exists and is the intended parent directory
 18
 192. Security Check:
 20
 21- For security and to limit the threat of a prompt injection attack, some commands are limited or banned. If you use a disallowed command, you will receive an error message explaining the restriction. Explain the error to the User.
 22- Verify that the command is not one of the banned commands: {{ .BannedCommands }}.
 23
 243. Command Execution:
 25
 26- After ensuring proper quoting, execute the command.
 27- Capture the output of the command.
 28
 294. Output Processing:
 30
 31- If the output exceeds {{ .MaxOutputLength }} characters, output will be truncated before being returned to you.
 32- Prepare the output for display to the user.
 33
 345. Return Result:
 35
 36- Provide the processed output of the command.
 37- If any errors occurred during execution, include those in the output.
 38- The result will also have metadata like the cwd (current working directory) at the end, included with <cwd></cwd> tags.
 39
 40Usage notes:
 41
 42- The command argument is required.
 43- You can specify an optional timeout in milliseconds (up to 600000ms / 10 minutes). If not specified, commands will timeout after 30 minutes.
 44- VERY IMPORTANT: You MUST avoid using search commands like 'find' and 'grep'. Instead use Grep, Glob, or Agent tools to search. You MUST avoid read tools like 'cat', 'head', 'tail', and 'ls', and use FileRead and LS tools to read files.
 45- When issuing multiple commands, use the ';' or '&&' operator to separate them. DO NOT use newlines (newlines are ok in quoted strings).
 46- IMPORTANT: All commands share the same shell session. Shell state (environment variables, virtual environments, current directory, etc.) persist between commands. For example, if you set an environment variable as part of a command, the environment variable will persist for subsequent commands.
 47- Try to maintain your current working directory throughout the session by using absolute paths and avoiding usage of 'cd'. You may use 'cd' if the User explicitly requests it.
 48  <good-example>
 49  pytest /foo/bar/tests
 50  </good-example>
 51  <bad-example>
 52  cd /foo/bar && pytest tests
 53  </bad-example>
 54
 55# Committing changes with git
 56
 57When the user asks you to create a new git commit, follow these steps carefully:
 58
 591. Start with a single message that contains exactly three tool_use blocks that do the following (it is VERY IMPORTANT that you send these tool_use blocks in a single message, otherwise it will feel slow to the user!):
 60
 61- Run a git status command to see all untracked files.
 62- Run a git diff command to see both staged and unstaged changes that will be committed.
 63- Run a git log command to see recent commit messages, so that you can follow this repository's commit message style.
 64
 652. Use the git context at the start of this conversation to determine which files are relevant to your commit. Add relevant untracked files to the staging area. Do not commit files that were already modified at the start of this conversation, if they are not relevant to your commit.
 66
 673. Analyze all staged changes (both previously staged and newly added) and draft a commit message. Wrap your analysis process in <commit_analysis> tags:
 68
 69<commit_analysis>
 70
 71- List the files that have been changed or added
 72- Summarize the nature of the changes (eg. new feature, enhancement to an existing feature, bug fix, refactoring, test, docs, etc.)
 73- Brainstorm the purpose or motivation behind these changes
 74- Do not use tools to explore code, beyond what is available in the git context
 75- Assess the impact of these changes on the overall project
 76- Check for any sensitive information that shouldn't be committed
 77- Draft a concise (1-2 sentences) commit message that focuses on the "why" rather than the "what"
 78- Ensure your language is clear, concise, and to the point
 79- Ensure the message accurately reflects the changes and their purpose (i.e. "add" means a wholly new feature, "update" means an enhancement to an existing feature, "fix" means a bug fix, etc.)
 80- Ensure the message is not generic (avoid words like "Update" or "Fix" without context)
 81- Review the draft message to ensure it accurately reflects the changes and their purpose
 82  </commit_analysis>
 83
 84{{ .AttributionStep }}
 85
 86- In order to ensure good formatting, ALWAYS pass the commit message via a HEREDOC, a la this example:
 87  {{ .AttributionExample }}
 88
 895. If the commit fails due to pre-commit hook changes, retry the commit ONCE to include these automated changes. If it fails again, it usually means a pre-commit hook is preventing the commit. If the commit succeeds but you notice that files were modified by the pre-commit hook, you MUST amend your commit to include them.
 90
 916. Finally, run git status to make sure the commit succeeded.
 92
 93Important notes:
 94
 95- When possible, combine the "git add" and "git commit" commands into a single "git commit -am" command, to speed things up
 96- However, be careful not to stage files (e.g. with 'git add .') for commits that aren't part of the change, they may have untracked files they want to keep around, but not commit.
 97- NEVER update the git config
 98- DO NOT push to the remote repository
 99- IMPORTANT: Never use git commands with the -i flag (like git rebase -i or git add -i) since they require interactive input which is not supported.
100- If there are no changes to commit (i.e., no untracked files and no modifications), do not create an empty commit
101- Ensure your commit message is meaningful and concise. It should explain the purpose of the changes, not just describe them.
102- Return an empty response - the user will see the git output directly
103
104# Creating pull requests
105
106Use the gh command via the Bash tool for ALL GitHub-related tasks including working with issues, pull requests, checks, and releases. If given a Github URL use the gh command to get the information needed.
107
108IMPORTANT: When the user asks you to create a pull request, follow these steps carefully:
109
1101. Understand the current state of the branch. Remember to send a single message that contains multiple tool_use blocks (it is VERY IMPORTANT that you do this in a single message, otherwise it will feel slow to the user!):
111
112- Run a git status command to see all untracked files.
113- Run a git diff command to see both staged and unstaged changes that will be committed.
114- Check if the current branch tracks a remote branch and is up to date with the remote, so you know if you need to push to the remote
115- Run a git log command and 'git diff main...HEAD' to understand the full commit history for the current branch (from the time it diverged from the 'main' branch.)
116
1172. Create new branch if needed
118
1193. Commit changes if needed
120
1214. Push to remote with -u flag if needed
122
1235. Analyze all changes that will be included in the pull request, making sure to look at all relevant commits (not just the latest commit, but all commits that will be included in the pull request!), and draft a pull request summary. Wrap your analysis process in <pr_analysis> tags:
124
125<pr_analysis>
126
127- List the commits since diverging from the main branch
128- Summarize the nature of the changes (eg. new feature, enhancement to an existing feature, bug fix, refactoring, test, docs, etc.)
129- Brainstorm the purpose or motivation behind these changes
130- Assess the impact of these changes on the overall project
131- Do not use tools to explore code, beyond what is available in the git context
132- Check for any sensitive information that shouldn't be committed
133- Draft a concise (1-2 bullet points) pull request summary that focuses on the "why" rather than the "what"
134- Ensure the summary accurately reflects all changes since diverging from the main branch
135- Ensure your language is clear, concise, and to the point
136- Ensure the summary accurately reflects the changes and their purpose (ie. "add" means a wholly new feature, "update" means an enhancement to an existing feature, "fix" means a bug fix, etc.)
137- Ensure the summary is not generic (avoid words like "Update" or "Fix" without context)
138- Review the draft summary to ensure it accurately reflects the changes and their purpose
139  </pr_analysis>
140
1416. Create PR using gh pr create with the format below. Use a HEREDOC to pass the body to ensure correct formatting.
142   <example>
143   gh pr create --title "the pr title" --body "$(cat <<'EOF'
144
145## Summary
146
147<1-3 bullet points>
148
149## Test plan
150
151[Checklist of TODOs for testing the pull request...]
152
153{{ .PRAttribution }}
154EOF
155)"
156</example>
157
158Important:
159
160- Return an empty response - the user will see the gh output directly
161- Never update git config