Skip to content

Add prompt-compression rules#175

Closed
ofershap wants to merge 3 commits intoPatrickJS:mainfrom
ofershap:add-prompt-compression-rules
Closed

Add prompt-compression rules#175
ofershap wants to merge 3 commits intoPatrickJS:mainfrom
ofershap:add-prompt-compression-rules

Conversation

@ofershap
Copy link

@ofershap ofershap commented Feb 21, 2026

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

  • Documentation
    • Added README entries describing "Prompt Compression" in multiple sections.
    • Published concise prompt-compression guidance: goals of ~70–80% token reduction, single-line/compact formatting, preservation of actionable info and structural boundaries, explicit exceptions for error/edge-case content, and a pre-insertion verification question to confirm no loss of required information.

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]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 21, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Adds prompt-compression documentation and a new .cursorrules guidance file defining single-line, token-efficient directive rules (targeting ~70–80% token reduction). README updated with two new “Prompt Compression” bullet links to the new rules file.

Changes

Cohort / File(s) Summary
Docs: README updates
README.md
Inserted two new "Prompt Compression" bullet points: one in Sponsorships and one in the "Other" section, both linking to the new rules path.
Prompt compression rules
rules/prompt-compression-cursorrules-prompt-file/.cursorrules
Added a new guidance file describing pipe-delimited indexing, single-line directives, abbreviated keys (req,opt,str,int,bool,len,min,max,def), brace expansion, path prefixes, required retrieval-led phrasing, pre-insertion check question, and targets/constraints for 70–80% token reduction while preserving actionable info and examples; forbids compressing error/edge-case docs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • PatrickJS

Poem

🐰 I nibble lines so they fit,
single-line hops, a tidy wit.
Tokens pruned but sense remains—
compact trails and nimble gains. 🥕

🚥 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 'Add prompt-compression rules' directly and accurately describes the main change: adding new cursor rules for prompt compression to the repository.
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.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 #2 prescribes 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]>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

Comment on lines +1 to +8
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
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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]>
@ofershap ofershap closed this by deleting the head repository Feb 22, 2026
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.

2 participants