Skip to content

Commit c59fa5e

Browse files
Apply PR #26821: core: reduce prompts
2 parents 4cdeb49 + 21bc8ac commit c59fa5e

4 files changed

Lines changed: 55 additions & 283 deletions

File tree

packages/opencode/src/session/prompt/default.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ Only use emojis if the user explicitly requests it. Avoid using emojis in all co
1717
IMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.
1818
IMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.
1919
IMPORTANT: Keep your responses short, since they will be displayed on a command line interface. You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is <answer>.", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...". Here are some examples to demonstrate appropriate verbosity:
20-
<example>
21-
user: 2 + 2
22-
assistant: 4
23-
</example>
24-
2520
<example>
2621
user: what is 2+2?
2722
assistant: 4
@@ -43,11 +38,6 @@ assistant: [use the ls tool to list the files in the current directory, then rea
4338
npm run dev
4439
</example>
4540

46-
<example>
47-
user: How many golf balls fit inside a jetta?
48-
assistant: 150000
49-
</example>
50-
5141
<example>
5242
user: what files are in the directory src/?
5343
assistant: [runs ls and sees foo.c, bar.c, baz.c]

packages/opencode/src/tool/shell/shell.txt

Lines changed: 9 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -10,68 +10,12 @@ IMPORTANT: This tool is for terminal operations like git, npm, docker, etc. DO N
1010

1111
${commandSection}
1212

13-
# Committing changes with git
14-
15-
Only create commits when requested by the user. If unclear, ask first. When the user asks you to create a new git commit, follow these steps carefully:
16-
17-
Git Safety Protocol:
18-
- NEVER update the git config
19-
- NEVER run destructive/irreversible git commands (like push --force, hard reset, etc) unless the user explicitly requests them
20-
- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it
21-
- NEVER run force push to main/master, warn the user if they request it
22-
- Avoid git commit --amend. ONLY use --amend when ALL conditions are met:
23-
(1) User explicitly requested amend, OR the commit succeeded and pre-commit hooks auto-modified files that need including — verify by checking `git log` that HEAD is the new commit before amending
24-
(2) HEAD commit was created by you in this conversation (verify: git log -1 --format='%an %ae')
25-
(3) Commit has NOT been pushed to remote (verify: git status shows "Your branch is ahead")
26-
- CRITICAL: If commit FAILED or was REJECTED by hook, NEVER amend - fix the issue and create a NEW commit
27-
- CRITICAL: If you already pushed to remote, NEVER amend unless user explicitly requests it (requires force push)
28-
- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
29-
30-
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following ${gitCommands} in parallel, each using the ${toolName} tool:
31-
- Run a git status command to see all untracked files.
32-
- Run a git diff command to see both staged and unstaged changes that will be committed.
33-
- Run a git log command to see recent commit messages, so that you can follow this repository's commit message style.
34-
2. Analyze all staged changes (both previously staged and newly added) and draft a commit message:
35-
- Summarize the nature of the changes (eg. new feature, enhancement to an existing feature, bug fix, refactoring, test, docs, etc.). 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.).
36-
- Do not commit files that likely contain secrets (.env, credentials.json, etc.). Warn the user if they specifically request to commit those files
37-
- Draft a concise (1-2 sentences) commit message that focuses on the "why" rather than the "what"
38-
- Ensure it accurately reflects the changes and their purpose
39-
3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands:
40-
- Add relevant untracked files to the staging area.
41-
- Create the commit with a message
42-
- Run git status after the commit completes to verify success.
43-
Note: git status depends on the commit completing, so run it sequentially after the commit.
44-
4. If the commit fails due to pre-commit hook, fix the issue and create a NEW commit (see amend rules above)
45-
46-
Important notes:
47-
- NEVER run additional commands to read or explore code, besides ${gitCommandRestriction}
48-
- NEVER use the TodoWrite or Task tools
49-
- DO NOT push to the remote repository unless the user explicitly asks you to do so
50-
- 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.
51-
- If there are no changes to commit (i.e., no untracked files and no modifications), do not create an empty commit
52-
53-
# Creating pull requests
54-
Use the gh command via the ${toolName} 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.
55-
56-
IMPORTANT: When the user asks you to create a pull request, follow these steps carefully:
57-
58-
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following ${gitCommands} in parallel using the ${toolName} tool, in order to understand the current state of the branch since it diverged from the main branch:
59-
- Run a git status command to see all untracked files
60-
- Run a git diff command to see both staged and unstaged changes that will be committed
61-
- 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
62-
- Run a git log command and `git diff [base-branch]...HEAD` to understand the full commit history for the current branch (from the time it diverged from the base branch)
63-
2. 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
64-
3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands in parallel:
65-
- Create new branch if needed
66-
- Push to remote with -u flag if needed
67-
- ${createPrInstruction}
68-
<example>
69-
${createPrExample}
70-
</example>
71-
72-
Important:
73-
- DO NOT use the TodoWrite or Task tools
74-
- Return the PR URL when you're done, so the user can see it
75-
76-
# Other common operations
77-
- View comments on a GitHub PR: gh api repos/foo/bar/pulls/123/comments
13+
# Git and GitHub
14+
- Only commit, amend, push, or create PRs when explicitly requested.
15+
- Before committing, inspect `git status`, `git diff`, and `git log --oneline -10`; stage only intended files and never commit secrets.
16+
- Write a concise commit message that matches the repo style.
17+
- Do not update git config, skip hooks, use interactive `-i`, force-push, or create empty commits unless explicitly requested.
18+
- If a commit fails or hooks reject it, fix the issue and create a new commit; do not amend the failed commit.
19+
- Before creating a PR, inspect status, diff, remote tracking, recent commits, and the diff from the base branch.
20+
- Review all commits included in the PR, not just the latest commit.
21+
- Use `gh` for GitHub tasks, including PRs, issues, checks, and releases; return the PR URL when done.

packages/opencode/src/tool/task.txt

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ Launch a new agent to handle complex, multistep tasks autonomously.
22

33
When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.
44

5-
When to use the Task tool:
6-
- When you are instructed to execute custom slash commands. Use the Task tool with the slash command invocation as the entire prompt. The slash command can take arguments. For example: Task(description="Check the file", prompt="/check-file path/to/file.py")
7-
85
When NOT to use the Task tool:
96
- If you want to read a specific file path, use the Read or Glob tool instead of the Task tool, to find the match more quickly
10-
- If you are searching for a specific class definition like "class Foo", use the Glob tool instead, to find the match more quickly
7+
- If you are searching for a specific class definition like "class Foo", use the Grep tool instead, to find the match more quickly
118
- If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead of the Task tool, to find the match more quickly
12-
- Other tasks that are not related to the agent descriptions above
9+
- If no available agent is a good fit for the task, use other tools directly
1310

1411

1512
Usage notes:
@@ -19,39 +16,3 @@ Usage notes:
1916
4. The agent's outputs should generally be trusted
2017
5. Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent. Tell it how to verify its work if possible (e.g., relevant test commands).
2118
6. If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.
22-
23-
Example usage (NOTE: The agents below are fictional examples for illustration only - use the actual agents listed above):
24-
25-
<example_agent_descriptions>
26-
"code-reviewer": use this agent after you are done writing a significant piece of code
27-
"greeting-responder": use this agent when to respond to user greetings with a friendly joke
28-
</example_agent_description>
29-
30-
<example>
31-
user: "Please write a function that checks if a number is prime"
32-
assistant: Sure let me write a function that checks if a number is prime
33-
assistant: First let me use the Write tool to write a function that checks if a number is prime
34-
assistant: I'm going to use the Write tool to write the following code:
35-
<code>
36-
function isPrime(n) {
37-
if (n <= 1) return false
38-
for (let i = 2; i * i <= n; i++) {
39-
if (n % i === 0) return false
40-
}
41-
return true
42-
}
43-
</code>
44-
<commentary>
45-
Since a significant piece of code was written and the task was completed, now use the code-reviewer agent to review the code
46-
</commentary>
47-
assistant: Now let me use the code-reviewer agent to review the code
48-
assistant: Uses the Task tool to launch the code-reviewer agent
49-
</example>
50-
51-
<example>
52-
user: "Hello"
53-
<commentary>
54-
Since the user is greeting, use the greeting-responder agent to respond with a friendly joke
55-
</commentary>
56-
assistant: "I'm going to use the Task tool to launch the with the greeting-responder agent"
57-
</example>

0 commit comments

Comments
 (0)