[FEATURE] context exclusion markers to prevent sending marked content to the API
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.
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.
Proposed Solution
I would like to be able to include something like this:
<!-- CLAUDE-CODE-EXCLUDE-START -->
This content is never sent to the API.
Zero tokens consumed.
Perfect for verbose human documentation.
<!-- CLAUDE-CODE-EXCLUDE-END -->
In order to mark sections of a file that should not be sent to the API.
Alternative Solutions
For now, I include human readable sibling files for the AI workflows that I generate.
Priority
Low - Nice to have
Feature Category
File operations
Use Case Example
- Hybrid Documentation - Maintain detailed human documentation alongside concise AI workflows in the same file
- Token Efficiency - Exclude verbose explanations, historical notes, and implementation details that AI doesn't need
- Team Notes - Include TODO items, project management notes, and team communication without affecting AI context
- Cost Reduction - Significantly reduce token usage for projects with extensive documentation
For an example code file:
## 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 AI Instructions)
Additional Context
Customer 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 -->This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗