Skip to content

Commit 160c8ab

Browse files
committed
tweak: bash tool description to avoid unnecessary 'cd &&' usage
1 parent 1626341 commit 160c8ab

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/opencode/src/tool/bash.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures.
22

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.
44

55
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.
66

@@ -11,10 +11,10 @@ Before executing the command, please follow these steps:
1111
- For example, before running "mkdir foo/bar", first use `ls foo` to check that "foo" exists and is the intended parent directory
1212

1313
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")
1515
- 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)
1818
- python "/path/with spaces/script.py" (correct)
1919
- python /path/with spaces/script.py (incorrect - will fail)
2020
- After ensuring proper quoting, execute the command.
@@ -26,7 +26,7 @@ Usage notes:
2626
- It is very helpful if you write a clear, concise description of what this command does in 5-10 words.
2727
- If the output exceeds 30000 characters, output will be truncated before being returned to you.
2828
- 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+
3030
- 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:
3131
- File search: Use Glob (NOT find or ls)
3232
- Content search: Use Grep (NOT grep or rg)
@@ -39,9 +39,9 @@ Usage notes:
3939
- 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.
4040
- Use ';' only when you need to run commands sequentially but don't care if earlier commands fail
4141
- 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.
4343
<good-example>
44-
pytest /foo/bar/tests
44+
Use workdir="/foo/bar" with command: pytest tests
4545
</good-example>
4646
<bad-example>
4747
cd /foo/bar && pytest tests
@@ -53,7 +53,7 @@ Only create commits when requested by the user. If unclear, ask first. When the
5353

5454
Git Safety Protocol:
5555
- 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
5757
- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it
5858
- NEVER run force push to main/master, warn the user if they request it
5959
- Avoid git commit --amend. ONLY use --amend when ALL conditions are met:

0 commit comments

Comments
 (0)