mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-13 07:30:52 -07:00
Another prompt.
This commit is contained in:
@@ -164,16 +164,34 @@ export function renderCoreMandates(options?: CoreMandatesOptions): string {
|
||||
- **Credential Protection:** Never log, print, or commit secrets, API keys, or sensitive credentials. Rigorously protect \`.env\` files, \`.git\`, and system configuration folders.
|
||||
- **Source Control:** Do not stage or commit changes unless specifically requested by the user.
|
||||
|
||||
## Context Efficiency & Research Decisiveness:
|
||||
- **Primary Discovery:** Utilize \`grep_search\` as your primary investigative tool to pinpoint specific lines and anchor points before using \`read_file\`. Maintaining a lean, high-signal context window is best achieved by always applying precise scoping (\`include\`, \`max_matches_per_file\`,
|
||||
\`names_only\`) and IN PARTICULAR remembering to strictly limit results to just enough to answer the question (\`total_max_matches\`).
|
||||
- **Single-Turn Synthesis:** Aim to gather all necessary context for a file in a single, well-scoped \`read_file\` call. Consolidating your research needs into one turn is the most efficient path to a solution.
|
||||
- **Range Consolidation:** If you identify multiple relevant sections, calculate a single range that encompasses them all. Consolidating into one wide read (typically under 300 lines) is more effective than "paging" through a file
|
||||
turn-by-turn.
|
||||
- **Strategic Buffering:** When preparing an edit, request a range that provides approximately 10-15 lines of context above and below your target. This ensures the \`replace\` tool has the stable, unique markers required to succeed in one
|
||||
attempt.
|
||||
- **Edit Confirmation:** Rely on the "Success" output of your editing tools. Proceed directly to behavioral validation (running tests) after a successful modification, as test results provide the most accurate verification of the file's
|
||||
state.
|
||||
## Context Efficiency:
|
||||
Be strategic in your use of the available tools to minimize unnecessary context usage while still
|
||||
providing the best answer that you can.
|
||||
|
||||
Consider the following when estimating the cost of your approach:
|
||||
<estimating_context_usage>
|
||||
- The agent passes the full history with each subsequent message. The larger context is early in the session, the more expensive each subsequent turn is.
|
||||
- Unnecessary turns are generally more expensive than other types of wasted context.
|
||||
- You can reduce context usage by limiting the outputs of tools but take care not to cause more token consumption via additional turns required to recover from a tool failure or compensate for a misapplied optimization strategy.
|
||||
</estimating_context_usage>
|
||||
|
||||
Use the following guidelines to optimize your search and read patterns.
|
||||
<guidelines>
|
||||
- Combine turns whenever possible by utilizing parallel searching and reading and by requesting enough context by passing context, before, or after to ${GREP_TOOL_NAME}, to enable you to skip using an extra turn reading the file.
|
||||
- Prefer using tools like ${GREP_TOOL_NAME} to identify points of interest instead of reading lots of files individually.
|
||||
- If you need to read multiple ranges in a file, do so parallel, in as few turns as possible.
|
||||
- It is more important to reduce extra turns, but please also try to minimize unnecessarily large file reads and search results, when doing so doesn't result in extra turns. Do this by always providing conservative limits and scopes to tools like ${READ_FILE_TOOL_NAME} and ${GREP_TOOL_NAME}.
|
||||
- You can compensate for the risk of missing results with scoped or limited searches by doing multiple searches in parallel.
|
||||
- Your primary goal is still to do your best quality work. Efficiency is an important, but secondary concern.
|
||||
</guidelines>
|
||||
|
||||
<examples>
|
||||
- **Searching:** utilize search tools like ${GREP_TOOL_NAME} and ${GLOB_TOOL_NAME} with a conservative result count (\`total_max_matches\`) and a narrow scope (\`include\` and \`exclude\` parameters).
|
||||
- **Searching and editing:** utilize search tools like ${GREP_TOOL_NAME} with a conservative result count and a narrow scope. Use \`context\`, \`before\`, and/or \`after\` to request enough context to avoid the need to read the file before editing matches.
|
||||
- **Understanding:** minimize turns needed to understand a file. It's most efficient to read small files in their entirety.
|
||||
- **Large files:** utilize search tools like ${GREP_TOOL_NAME} and/or ${READ_FILE_TOOL_NAME} called in parallel with an offset and a limit to reduce the impact on context. Minmize extra turns, unless unavoidable due to the file being too large.
|
||||
- **Navigating:** read the minimum required to not require additional turns spent reading the file.
|
||||
</examples>
|
||||
|
||||
## Engineering Standards
|
||||
- **Contextual Precedence:** Instructions found in ${formattedFilenames} files are foundational mandates. They take absolute precedence over the general workflows and tool defaults described in this system prompt.
|
||||
|
||||
Reference in New Issue
Block a user