Conversation
Compress docs, prompts, and context into minimal tokens for AGENTS.md. Based on Vercel's research showing compressed passive context achieves 100% eval pass rate vs 53% baseline. Co-authored-by: Cursor <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdds prompt-compression documentation and a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
rules/prompt-compression-cursorrules-prompt-file/.cursorrules (1)
17-18: Nit: multi-line question is inconsistent with rule#2.The verification question wraps across two lines while rule
#2prescribes single-line directives. Consider keeping it on one line.✏️ Suggested fix
-Before adding content to AGENTS.md, ask: "Can this be expressed in fewer tokens without losing -information the agent needs to act on?" +Before adding content to AGENTS.md, ask: "Can this be expressed in fewer tokens without losing information the agent needs to act on?"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rules/prompt-compression-cursorrules-prompt-file/.cursorrules` around lines 17 - 18, The verification question currently breaks across two lines ("Can this be expressed in fewer tokens without losing information the agent needs to act on?") which violates rule `#2`'s single-line directive; update the .cursorrules entry so that the full question is on one line (no newline between "tokens" and "information"), keeping the exact wording and reference to AGENTS.md intact to preserve intent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Line 280: Move the "Prompt Compression" list item (the line linking
./rules/prompt-compression-cursorrules-prompt-file/.cursorrules) from the end of
the "Other" section into the alphabetical position after "Next.js (Type LLM)"
and before "Unity (C#)" in README.md, update its description to remove the
overclaim "zero information loss" and instead state that it preserves actionable
information while stripping explanatory prose (matching the .cursorrules rule `#3`
and its phrasing), and delete the duplicate entry at the bottom of the section
so only the correctly placed, updated listing remains.
---
Nitpick comments:
In `@rules/prompt-compression-cursorrules-prompt-file/.cursorrules`:
- Around line 17-18: The verification question currently breaks across two lines
("Can this be expressed in fewer tokens without losing information the agent
needs to act on?") which violates rule `#2`'s single-line directive; update the
.cursorrules entry so that the full question is on one line (no newline between
"tokens" and "information"), keeping the exact wording and reference to
AGENTS.md intact to preserve intent.
…curacy - Move Prompt Compression entry to correct alphabetical position in Other section - Remove duplicate entry at end of section - Replace overclaimed "zero information loss" with accurate "preserving actionable information" - Fix multi-line question to single line (consistent with rule #2) Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
rules/prompt-compression-cursorrules-prompt-file/.cursorrules (2)
15-15: "Never" is overly absolute for error messages."Never compress error messages or edge case docs" prohibits compression even for verbose, repetitive, or boilerplate error strings. This may be intentional (error messages must survive verbatim), but if so, it is worth noting that this carve-out can represent a significant portion of the context budget in practice. Consider "Avoid compressing…" if the intent is a strong default rather than a hard invariant.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rules/prompt-compression-cursorrules-prompt-file/.cursorrules` at line 15, The rule text "Never compress error messages or edge case docs" is overly absolute; update the .cursorrules entry to a softer default such as "Avoid compressing error messages or edge case docs" and/or add a clarifying sentence describing exceptions (e.g., allow compression for verbose, repetitive, or boilerplate errors when necessary and when exact verbatim preservation is not required) so the intent is clear without hard-prohibiting legitimate compression use; locate and edit the rule string "Never compress error messages or edge case docs" in the .cursorrules file and replace or annotate it accordingly.
12-13: "Preserve all actionable information" conflicts with the 70–80% reduction target.These two goals are stated as absolutes and can pull in opposite directions — 70–80% reduction is only achievable if some content is either paraphrased, elided, or restructured, which cannot simultaneously guarantee zero loss across all actionable content. Consider softening "all" to "essential" or "agent-critical" to give agents a clear tiebreaker when the two goals conflict.
✏️ Suggested wording
-- Preserve all actionable information and structural boundaries +- Preserve essential actionable information and structural boundaries🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rules/prompt-compression-cursorrules-prompt-file/.cursorrules` around lines 12 - 13, The two rules "Target 70-80% token reduction" and "Preserve all actionable information and structural boundaries" conflict; update the second bullet ("Preserve all actionable information and structural boundaries") to soften "all" to something like "essential" or "agent-critical" actionable information and add a tie-breaker that prioritizes meeting the "Target 70-80% token reduction" while retaining agent-critical details and structural boundaries when trade-offs are required; specifically modify the line "Preserve all actionable information and structural boundaries" to "Preserve essential (agent‑critical) actionable information and structural boundaries; if necessary, prefer the 70–80% reduction while ensuring agent‑critical details are retained."
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@rules/prompt-compression-cursorrules-prompt-file/.cursorrules`:
- Line 15: The rule text "Never compress error messages or edge case docs" is
overly absolute; update the .cursorrules entry to a softer default such as
"Avoid compressing error messages or edge case docs" and/or add a clarifying
sentence describing exceptions (e.g., allow compression for verbose, repetitive,
or boilerplate errors when necessary and when exact verbatim preservation is not
required) so the intent is clear without hard-prohibiting legitimate compression
use; locate and edit the rule string "Never compress error messages or edge case
docs" in the .cursorrules file and replace or annotate it accordingly.
- Around line 12-13: The two rules "Target 70-80% token reduction" and "Preserve
all actionable information and structural boundaries" conflict; update the
second bullet ("Preserve all actionable information and structural boundaries")
to soften "all" to something like "essential" or "agent-critical" actionable
information and add a tie-breaker that prioritizes meeting the "Target 70-80%
token reduction" while retaining agent-critical details and structural
boundaries when trade-offs are required; specifically modify the line "Preserve
all actionable information and structural boundaries" to "Preserve essential
(agent‑critical) actionable information and structural boundaries; if necessary,
prefer the 70–80% reduction while ensuring agent‑critical details are retained."
| When writing or editing AGENTS.md, CLAUDE.md, .cursorrules, or any agent context file: | ||
|
|
||
| 1. Use pipe-delimited format for file indexes and structured references | ||
| 2. Compress rules into single-line directives, not multi-paragraph explanations | ||
| 3. Strip explanatory prose - keep only actionable content the agent needs | ||
| 4. Use abbreviated keys (req, opt, str, int, bool, len, min, max, def) | ||
| 5. Flatten nested hierarchies with brace expansion and path prefixes | ||
| 6. Include "Prefer retrieval-led reasoning over pre-training-led reasoning" when referencing docs |
There was a problem hiding this comment.
The file doesn't follow its own rules, and Rule 6 adds mandatory per-reference token overhead.
Two separate concerns here:
1. Self-referential inconsistency (lines 1–8).
The scope on line 1 explicitly includes .cursorrules ("any agent context file"). By its own Rules 2–5, this file should be written as single-line directives, use abbreviated keys, pipe-delimited format, and strip prose. Instead, it uses a multi-line numbered prose block. An agent instructed to update this file will face a contradiction: follow the rules (and rewrite the file) or preserve the current format. At minimum, add a self-exemption comment, or apply the rules to the file itself.
💡 Illustrative compressed form of the rule block (applying its own rules)
-When writing or editing AGENTS.md, CLAUDE.md, .cursorrules, or any agent context file:
-
-1. Use pipe-delimited format for file indexes and structured references
-2. Compress rules into single-line directives, not multi-paragraph explanations
-3. Strip explanatory prose - keep only actionable content the agent needs
-4. Use abbreviated keys (req, opt, str, int, bool, len, min, max, def)
-5. Flatten nested hierarchies with brace expansion and path prefixes
-6. Include "Prefer retrieval-led reasoning over pre-training-led reasoning" when referencing docs
+# agent-ctx rules (AGENTS.md|CLAUDE.md|.cursorrules|any agent ctx file)
+1. idx:pipe-delimited|2. rules:single-line|3. strip prose,keep actionable|4. abbrev keys:req,opt,str,int,bool,len,min,max,def|5. flatten w/ brace-expansion+path-prefix|6. docs-ref→prepend "Prefer retrieval-led over pre-training-led reasoning"2. Rule 6 adds fixed per-reference token cost (line 8).
Mandating a verbatim 8-token phrase on every doc reference introduces a predictable per-reference overhead. In context files with many doc references, this cumulative cost can noticeably counteract the 70–80% reduction target. Consider making this a one-time header directive (e.g., in the file preamble) rather than a per-reference requirement.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| When writing or editing AGENTS.md, CLAUDE.md, .cursorrules, or any agent context file: | |
| 1. Use pipe-delimited format for file indexes and structured references | |
| 2. Compress rules into single-line directives, not multi-paragraph explanations | |
| 3. Strip explanatory prose - keep only actionable content the agent needs | |
| 4. Use abbreviated keys (req, opt, str, int, bool, len, min, max, def) | |
| 5. Flatten nested hierarchies with brace expansion and path prefixes | |
| 6. Include "Prefer retrieval-led reasoning over pre-training-led reasoning" when referencing docs | |
| # agent-ctx rules (AGENTS.md|CLAUDE.md|.cursorrules|any agent ctx file) | |
| 1. idx:pipe-delimited|2. rules:single-line|3. strip prose,keep actionable|4. abbrev keys:req,opt,str,int,bool,len,min,max,def|5. flatten w/ brace-expansion+path-prefix|6. docs-ref→prepend "Prefer retrieval-led over pre-training-led reasoning" |
…erence Addresses review feedback about Rule 6 adding cumulative per-reference token overhead that counteracts the compression target. Co-authored-by: Cursor <[email protected]>
Adds cursor rules for prompt compression - compressing docs, prompts, and context into minimal tokens for AGENTS.md.
Based on Vercel's research showing compressed passive context in AGENTS.md achieves 100% eval pass rate vs 53% baseline.
The rules enforce token-efficient formatting: pipe-delimited indexes, single-line directives, abbreviated keys, brace expansion, and retrieval-led reasoning directives.
Full plugin with skill and commands: https://github.com/ofershap/prompt-compression
Made with Cursor
Summary by CodeRabbit