Skip to content

[wip]chore: optimize Claude Code config for context efficiency#190

Closed
RealiCZ wants to merge 1 commit intomainfrom
cz/chore/agent
Closed

[wip]chore: optimize Claude Code config for context efficiency#190
RealiCZ wants to merge 1 commit intomainfrom
cz/chore/agent

Conversation

@RealiCZ
Copy link
Copy Markdown
Collaborator

@RealiCZ RealiCZ commented Mar 16, 2026

Summary

Optimize Claude Code configuration for context efficiency, reducing always-loaded token overhead by ~60%.

Layer Before After
AGENTS.md ~2900 tokens, no compression guide, constraints buried in Caveats ~1160 tokens, NEVER/ALWAYS/Verification/Compact Instructions
Rules None New rust.md (coding conventions) and architecture.md (domain knowledge), loaded on demand
Skills Verbose description (~50 tokens) Trigger-focused description (~18 tokens)
Hooks None PostToolUse (auto cargo check on .rs edits) + Notification (desktop alert)

AGENTS.md changes

  • Extracted domain knowledge (dual gas model, resource limits, gas detention, system contracts, external
    environment) to .claude/rules/architecture.md.
  • Extracted Rust coding conventions (no_std, cargo sort, default-features) to .claude/rules/rust.md.
  • Replaced free-form Caveats with structured NEVER / ALWAYS / Verification / Compact Instructions sections.

Context overhead comparison

Item Before After
AGENTS.md ~2900 tokens ~1160 tokens
Skill descriptors ~95 tokens ~30 tokens
Rules (always loaded) 0 0 (on demand)
Hooks context cost 0 0 (not in context)
Total always-loaded ~2995 tokens ~1190 tokens

Comment thread .claude/settings.json
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"$NOTIFICATION_MESSAGE\" with title \"Claude Code\"'"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

osascript? only applicable on MacOS. I don't think such command should be pushed to git.

Comment thread .claude/settings.json
"type": "command",
"command": "cargo check -p mega-evm 2>&1 | head -30",
"timeout": 30000,
"statusMessage": "Running cargo check..."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sometimes the agent is in the middle of a large refactor/implementation and one edit only modifies parts of the code. At this point, the project may be not compilable. I think this hook is unnecessary. We can just ask the agent to always check compilation after edit (the logical multi-file edits, not a single edit) in the AGENTS.md or similar system prompts.

@RealiCZ RealiCZ marked this pull request as draft March 16, 2026 08:52
@RealiCZ RealiCZ changed the title chore: optimize Claude Code config for context efficiency [wip]chore: optimize Claude Code config for context efficiency Mar 16, 2026
@RealiCZ RealiCZ closed this Mar 30, 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