[FEATURE] Add support for context exclusion markers to prevent sending marked content to the API

Resolved 💬 1 comment Opened Oct 1, 2025 by kwhiteside-favor Closed Oct 1, 2025

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Claude Code should support special markers that exclude content from being sent to the API, similar to how .gitignore prevents files from being tracked. This would allow developers to maintain comprehensive human documentation alongside AI instructions without consuming context tokens.

Proposed Solution

I'd like to be able to write something like this within a memory file:

  <!-- CLAUDE-CODE-EXCLUDE-START -->
  This content is never sent to the API.
  Zero tokens consumed.
  Perfect for verbose human documentation.
  <!-- CLAUDE-CODE-EXCLUDE-END -->

Alternative Solutions

For now, I keep human-readable versions of AI directives in a sibling file labeled .human.md, but having it inline would be better.

Priority

Low - Nice to have

Feature Category

File operations

Use Case Example

S2S Authentication Setup

Quick Setup: Add micronaut-s2s dependency, configure client, add token to AWS Secrets.

<!-- CLAUDE-CODE-EXCLUDE-START -->
### Historical Context for Team
We migrated from OAuth2 to S2S in Q3 2024 due to performance issues
with token refresh cycles. The old OAuth implementation is deprecated
but remains in the codebase for backward compatibility.

Migration challenges included:

  • Token rotation timing issues
  • Rate limiting from auth service
  • Gradual rollout across 15 services

Contact Kevin (auth lead) or Sarah (platform team) for questions.
Previous RFCs: DOC-1234, DOC-5678
<!-- CLAUDE-CODE-EXCLUDE-END -->

Implementation Steps:

  1. Add dependency to build.gradle.kts
  2. Configure in application.yaml

<other instructions to the AI>

Additional Context

Benefits

  • Reduced API costs - Excluded content never consumes tokens
  • Better documentation - No compromise between human readability and AI efficiency
  • Cleaner context - AI receives only relevant information
  • Preprocessing efficiency - Content stripped before API call, not after

Alternative Marker Suggestions

  • <!-- EXCLUDE-FROM-CONTEXT -->...<!-- END-EXCLUDE -->
  • <!-- HUMAN-ONLY -->...<!-- END-HUMAN-ONLY -->
  • <!-- NO-CONTEXT -->...<!-- END-NO-CONTEXT -->

Implementation Notes

Similar to preprocessor directives, the REPL would strip marked sections during file reading, before adding to context.
This ensures excluded content never reaches the token count or API payload.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗