You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/opencode/src/tool/bash.txt
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures.
2
2
3
-
All commands run in ${directory} by default. Use the `workdir` parameter if you need to run a command in a different directory.
3
+
All commands run in ${directory} by default. Use the `workdir` parameter if you need to run a command in a different directory. AVOID using `cd <directory> && <command>` patterns - use `workdir` instead.
4
4
5
5
IMPORTANT: This tool is for terminal operations like git, npm, docker, etc. DO NOT use it for file operations (reading, writing, editing, searching, finding files) - use the specialized tools for this instead.
6
6
@@ -11,10 +11,10 @@ Before executing the command, please follow these steps:
11
11
- For example, before running "mkdir foo/bar", first use `ls foo` to check that "foo" exists and is the intended parent directory
12
12
13
13
2. Command Execution:
14
-
- Always quote file paths that contain spaces with double quotes (e.g., cd "path with spaces/file.txt")
14
+
- Always quote file paths that contain spaces with double quotes (e.g., rm "path with spaces/file.txt")
15
15
- Examples of proper quoting:
16
-
- cd "/Users/name/My Documents" (correct)
17
-
- cd /Users/name/My Documents (incorrect - will fail)
16
+
- mkdir "/Users/name/My Documents" (correct)
17
+
- mkdir /Users/name/My Documents (incorrect - will fail)
18
18
- python "/path/with spaces/script.py" (correct)
19
19
- python /path/with spaces/script.py (incorrect - will fail)
20
20
- After ensuring proper quoting, execute the command.
@@ -26,7 +26,7 @@ Usage notes:
26
26
- It is very helpful if you write a clear, concise description of what this command does in 5-10 words.
27
27
- If the output exceeds 30000 characters, output will be truncated before being returned to you.
28
28
- You can use the `run_in_background` parameter to run the command in the background, which allows you to continue working while the command runs. You can monitor the output using the Bash tool as it becomes available. You do not need to use '&' at the end of the command when using this parameter.
29
-
29
+
30
30
- Avoid using Bash with the `find`, `grep`, `cat`, `head`, `tail`, `sed`, `awk`, or `echo` commands, unless explicitly instructed or when these commands are truly necessary for the task. Instead, always prefer using the dedicated tools for these commands:
31
31
- File search: Use Glob (NOT find or ls)
32
32
- Content search: Use Grep (NOT grep or rg)
@@ -39,9 +39,9 @@ Usage notes:
39
39
- If the commands depend on each other and must run sequentially, use a single Bash call with '&&' to chain them together (e.g., `git add . && git commit -m "message" && git push`). For instance, if one operation must complete before another starts (like mkdir before cp, Write before Bash for git operations, or git add before git commit), run these operations sequentially instead.
40
40
- Use ';' only when you need to run commands sequentially but don't care if earlier commands fail
41
41
- DO NOT use newlines to separate commands (newlines are ok in quoted strings)
42
-
- 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.
42
+
- AVOID using `cd <directory> && <command>`. Use the `workdir` parameter to change directories instead.
43
43
<good-example>
44
-
pytest /foo/bar/tests
44
+
Use workdir="/foo/bar" with command: pytest tests
45
45
</good-example>
46
46
<bad-example>
47
47
cd /foo/bar && pytest tests
@@ -53,7 +53,7 @@ Only create commits when requested by the user. If unclear, ask first. When the
53
53
54
54
Git Safety Protocol:
55
55
- NEVER update the git config
56
-
- NEVER run destructive/irreversible git commands (like push --force, hard reset, etc) unless the user explicitly requests them
56
+
- NEVER run destructive/irreversible git commands (like push --force, hard reset, etc) unless the user explicitly requests them
57
57
- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it
58
58
- NEVER run force push to main/master, warn the user if they request it
59
59
- Avoid git commit --amend. ONLY use --amend when ALL conditions are met:
0 commit comments