Skip to content

chore: Codex-inspired prompt improvements for reliability and token efficiency#236

Merged
marcusquinn merged 2 commits intomainfrom
chore/codex-prompt-improvements
Jan 26, 2026
Merged

chore: Codex-inspired prompt improvements for reliability and token efficiency#236
marcusquinn merged 2 commits intomainfrom
chore/codex-prompt-improvements

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Jan 26, 2026

Summary

  • Add dirty worktree awareness to build.txt: never revert user changes, never git reset --hard unless explicitly requested
  • Strengthen file re-read guidance in build-plus.md: don't re-read after successful edits (saves tokens)
  • Add ambition vs precision calibration: be creative for greenfield, surgical for existing codebases
  • Improve test strategy: specific-to-broad testing, only add tests when codebase already has them

Motivation

Comparative analysis of OpenAI Codex CLI system prompts (openai/codex repo) identified four patterns that complement our existing prompt architecture. All changes are additive refinements -- no existing guidance was removed or contradicted.

Changes

  • .agent/prompts/build.txt - 2 lines added (git safety)
  • .agent/build-plus.md - 3 sections refined (file reading, testing, ambition calibration)

Summary by CodeRabbit

  • Chores
    • Replaced “test frequently” with a specific test order: run narrow/specific tests first, then broaden to the full suite; add a test if one exists for the codebase.
    • Don’t re-read files after a successful edit unless preparing a second edit or another tool may have modified content.
    • Added safety guardrails: never revert or force-reset files you didn’t change and never run destructive VCS commands unless the user explicitly requests it.
    • Clarified ambition guidance for task types.

✏️ Tip: You can customize this high-level summary in your review settings.

…en efficiency

- Add dirty worktree awareness: never revert user changes, never git reset --hard
- Strengthen file re-read guidance: don't verify after successful edits
- Add ambition vs precision calibration for greenfield vs existing codebases
- Improve test strategy: specific-to-broad, add tests only when codebase has them

Inspired by OpenAI Codex CLI system prompts (openai/codex).
@gemini-code-assist
Copy link

Summary of Changes

Hello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces several prompt improvements inspired by OpenAI Codex CLI system prompts, aiming to enhance the reliability and token efficiency of the agent's operations. The changes are additive refinements to the existing prompt architecture, focusing on safer Git interactions, smarter file handling, calibrated development approaches, and a more strategic testing methodology. The overall goal is to make the agent's behavior more robust and resource-efficient without altering its core functionality.

Highlights

  • Git Safety Guidelines: Added explicit instructions to build.txt to prevent unintended Git operations, such as reverting user changes or using git reset --hard, unless specifically requested by the user. This enhances worktree awareness and reliability.
  • Optimized File Re-read Guidance: Refined the guidance in build-plus.md to avoid redundant file re-reads after successful edits or writes, saving tokens and improving efficiency. Files should only be re-read if a second edit is needed or content has genuinely changed.
  • Ambition vs. Precision Calibration: Introduced new guidance for calibrating ambition based on the task type: encouraging creativity for greenfield projects and surgical precision for changes within existing codebases to respect surrounding code and minimize disruption.
  • Improved Testing Strategy: Updated testing recommendations to advocate for a specific-to-broad approach, starting with narrow tests and expanding as confidence grows. Also, clarified that new tests should only be added if the codebase already has an existing testing framework.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

Walkthrough

Two agent framework documentation files were updated: one adds Ambition calibration, restructures testing guidance, and refines file-reading best practices; the other appends safety reminders to the pre-edit-check workflow about not reverting unrelated changes and avoiding certain git commands without explicit user consent.

Changes

Cohort / File(s) Summary
Agent Framework Guidance
.agent/build-plus.md
Adds Ambition calibration guidance (greenfield = ambitious, existing code = surgical); replaces "Test frequently" with "Test specific-to-broad" (narrowest-first, then widen; add tests if repo has tests; do not add testing framework if none exists); clarifies file-reading rules (do not re-read after a successful edit unless preparing a second edit or another tool may have modified content).
Pre-edit Safety Prompts
.agent/prompts/build.txt
Appends two safety reminders to pre-edit-check: never revert changes you did not make without explicit user request and STOP + ask when unexpected uncommitted changes are detected; never run git reset --hard or git checkout -- <file> unless the user explicitly requests it.

Sequence Diagram(s)

(omitted — changes are documentation and minor prompt updates; no new multi-component control flow introduced)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

✨ A tweak, a rule, a careful line,
Ambition tuned to build or refine.
Tests start small, then widen the view,
Git safety whispers: "Ask, don't undo."
Agents hum smarter—steady and true.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: prompt improvements for reliability and token efficiency across two key files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several excellent improvements to the agent prompts, enhancing safety with git operations, refining the testing strategy, and providing guidance on ambition calibration. The changes are clear and well-aligned with the goal of improving reliability and efficiency. I have one suggestion in .agent/build-plus.md to make the file re-reading guidance slightly less restrictive to avoid potential issues with stale file content when files are modified by external tools.

- You encounter an error suggesting stale context
- Use internal memory and previous context to avoid redundant reads
- After a successful Edit or Write, do NOT re-read the file to verify. The tool fails if the edit didn't apply -- a successful return means it worked.
- Only re-read a file if you need to make a SECOND edit (to refresh context for the new state).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This rule is a good specific example, but the word 'Only' makes it too restrictive. It doesn't account for cases where a file might be modified by other means, such as a bash command. This could cause the agent to work with stale file content, leading to errors. The previous version's guidance to re-read if you 'suspect content has changed' was a safer, more general heuristic. I suggest rephrasing this to be less restrictive while still guiding towards token efficiency.

Suggested change
- Only re-read a file if you need to make a SECOND edit (to refresh context for the new state).
- Re-read a file to refresh context before a second edit, or if you suspect another tool has modified it.

@augmentcode
Copy link

augmentcode bot commented Jan 26, 2026

🤖 Augment PR Summary

Summary: Refines agent build prompts to improve reliability and token efficiency.

Adds guidance for safer git behavior, ambition calibration, targeted testing, and reduced redundant file re-reads.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

4. Main repo (`~/Git/{repo}/`) should always stay on `main`
5. Feature work happens in worktrees (`~/Git/{repo}-{type}-{name}/`)
For loop mode: `pre-edit-check.sh --loop-mode --task "description"`
- NEVER revert changes you did not make. If you notice unexpected uncommitted changes in the worktree, STOP and ask the user.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NEVER revert changes you did not make reads like it forbids reverting unexpected/uncommitted changes even when the user explicitly asks to revert them, which seems to conflict with the next bullet’s “unless the user explicitly requests it”. Consider clarifying the exception case so the guidance is internally consistent.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

@@ -360,12 +365,10 @@ Communicate clearly and concisely in a casual, friendly yet professional tone:

**Always check if you have already read a file before reading it again.**

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The claim that “the tool fails if the edit didn’t apply” may be too absolute—an edit can succeed yet still be unintended (e.g., wrong match or unexpected formatting), so forbidding re-reads purely for verification could let mistakes slip through. Consider allowing a re-read when you need to confirm the resulting content, not only when making a second edit.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 457 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Mon Jan 26 18:19:51 UTC 2026: Code review monitoring started
Mon Jan 26 18:19:52 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 457
Mon Jan 26 18:19:52 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Mon Jan 26 18:19:54 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 457
  • VULNERABILITIES: 0

Generated on: Mon Jan 26 18:21:18 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

- Clarify revert rule with explicit exception clause (Augment feedback)
- Soften file re-read guidance to allow re-reads when external tools may
  have modified files (Gemini + Augment feedback)
@sonarqubecloud
Copy link

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 457 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Mon Jan 26 18:23:24 UTC 2026: Code review monitoring started
Mon Jan 26 18:23:25 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 457
Mon Jan 26 18:23:25 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Mon Jan 26 18:23:27 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 457
  • VULNERABILITIES: 0

Generated on: Mon Jan 26 18:24:52 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@marcusquinn marcusquinn merged commit 52b8308 into main Jan 26, 2026
8 of 9 checks passed
@marcusquinn marcusquinn deleted the chore/codex-prompt-improvements branch February 21, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant