| id | 65-context-token-optimization-anti-bloat-checklist |
| name | Anti-Bloat Checklist |
| description | Checklist for detecting and removing bloat in context, prompts, and responses to reduce token cost and improve signal-to-noise ratio |
| version | 1.0.0 |
| status | Active |
| owner | AI Engineering Team |
| last_updated | "2025-02-15T00:00:00.000Z" |
| category | AI-RAG |
| tags | ["token-optimization","bloat","prompts","context","cost-optimization"] |
| stack | ["Not Applicable"] |
| difficulty | Beginner |
Anti-Bloat Checklist
Skill Profile
Overview
Checklist for verifying that context/prompt/response contains "bloat" - unnecessary information, redundancies, or token usage that doesn't add value.
Why This Matters
- Token cost: Every token has a cost
- Context limit: Window is limited, use it wisely
- Signal-to-noise: Bloat makes AI lose focus
- Speed: Fewer tokens = faster response
Core Concepts & Rules
1. Filler Words
ā Bloat:
"Basically, I think we should essentially try to implement this feature"
ā
Clean:
"Implement this feature"
Common fillers:
- basically, essentially, actually
- just, simply, really
- kind of, sort of
- very, quite, rather
2. Redundancy
ā Bloat:
"The API endpoint returns a JSON response in JSON format"
ā
Clean:
"The API returns JSON"
Redundant patterns:
- "JSON response in JSON format"
- "database DB"
- "API endpoint API"
- Repeating same info in multiple places
3. Unnecessary Context
ā Bloat:
Including entire file when only need 10 lines
ā
Clean:
Include only relevant snippet with line numbers
Example:
"See lines 45-55 in auth.ts for implementation"
Inputs / Outputs / Contracts
Inputs
- Prompts and instructions
- Context and documentation
- Code and configuration
- Responses and outputs
- Token usage metrics
Outputs
- Optimized prompts
- Trimmed context
- Concise responses
- Token savings
- Cost reduction
Contracts
- Input Validation: All inputs must be valid text/code
- Output Format: Outputs follow anti-bloat checklist standards
- Token Budget: Outputs respect configured token limits
- Quality Guarantee: Optimized content maintains semantic meaning
- Cost Tracking: Token savings are measurable and reportable
Skill Composition
Quick Start
Quick Wins
1. Remove Filler Words
Find and replace:
- "basically" ā ""
- "essentially" ā ""
- "just" ā ""
- "simply" ā ""
- "really" ā ""
Typical savings: 5-10%
2. Use Imperative Mood
ā "Could you please write..."
ā
"Write..."
ā "I would like you to..."
ā
"Create..."
Savings: 30-50% in prompts
3. Snippets Over Full Files
ā Include entire 500-line file
ā
Include 20-line relevant function
Savings: 90%+ per file
Assumptions
- AI models have token limits
- Token usage has cost implications
- Bloat reduces AI performance
- Context needs optimization
- Responses should be concise
Compatibility
- AI Models: GPT-4, Claude, etc.
- Token Counters: tiktoken, etc.
- Languages: All languages supported
- Context Types: Code, docs, prompts
Test Scenario Matrix
| Scenario | Input | Expected Output | Verification |
|---|
| Remove filler | Prompt with fillers | Clean prompt | Token count reduced |
| Use imperative | Passive voice prompt | Active voice prompt | Token count reduced |
| Snippet vs file | Full file | Relevant snippet | Token count reduced |
| Output limit | Long response | Constrained response | Length constraint met |
Technical Guardrails
Prompt Requirements
- All prompts MUST use imperative mood
- All prompts MUST avoid filler words
- All prompts MUST specify output format
- All prompts MUST include constraints
Context Requirements
- All context MUST be relevant to task
- All context MUST be current and accurate
- All context MUST use snippets over full files
- All context MUST avoid redundancy
Response Requirements
- All responses MUST be concise
- All responses MUST avoid preamble
- All responses MUST follow format constraints
- All responses MUST avoid repetition
Security Threat Model
Threats Addressed
- Token waste: Bloat detection and removal
- Cost overruns: Token budgeting
- Context overflow: Context limits enforced
- Quality degradation: Signal-to-noise monitoring
Mitigation Strategies
- Implement token budgets
- Use automated bloat detection
- Monitor token usage
- Enforce context limits
Domain-Specific Modules
Token Counter Module
import { encode } from "gpt-tokenizer";
export function countTokens(text: string): number {
return encode(text).length;
}
export function estimateCost(tokens: number, model: string = "gpt-4"): number {
const pricing = {
"gpt-4": 0.03 / 1000,
"gpt-3.5-turbo": 0.002 / 1000,
};
return tokens * pricing[model];
}
Bloat Analyzer Module
export interface BloatAnalysis {
fillerWords: number;
redundantPhrases: number;
unnecessaryContext: number;
totalBloatTokens: number;
bloatPercentage: number;
}
export function analyzeBloat(text: string): BloatAnalysis {
const fillerWords = ["basically", "essentially", "just", "simply", "really"];
const fillerCount = text.split(/\s+/).filter(word =>
fillerWords.some(filler => word.toLowerCase().includes(filler))
).length;
return {
fillerWords: fillerCount,
redundantPhrases: 0,
unnecessaryContext: 0,
totalBloatTokens: fillerCount * 2,
bloatPercentage: 0,
};
}
Token Budget Module
export interface TokenBudget {
systemPrompt: number;
userPrompt: number;
contextPerFile: number;
totalContext: number;
maxResponse: number;
}
export const TOKEN_BUDGETS: TokenBudget = {
systemPrompt: 200,
userPrompt: 150,
contextPerFile: 500,
totalContext: 4000,
maxResponse: 1000,
};
export function checkBudget(content: string, type: keyof TokenBudget): boolean {
const tokens = countTokens(content);
const budget = TOKEN_BUDGETS[type];
return tokens <= budget;
}
Release, Rollback & Ops Notes
Release Process
- Define bloat detection rules
- Implement token counting
- Create checklists
- Test with sample prompts
- Deploy to production
- Monitor token usage
- Adjust thresholds
Rollback Procedure
- Revert bloat detection rules
- Restore original prompts
- Monitor quality
- Roll back if quality degrades
Operational Procedures
- Token monitoring: Track token usage
- Bloat detection: Run automated checks
- Cost tracking: Monitor AI costs
- Quality monitoring: Ensure quality maintained
Code Quality & Documentation
Bloat Detection Standards
- Use automated token counting
- Define clear bloat patterns
- Create actionable checklists
- Track token savings
- Monitor quality impact
Documentation Requirements
- Document all bloat patterns
- Provide examples of bloat
- Include quick wins
- Document token budgets
- Track cost savings
Agent Directives & Error Recovery
Agent Behavior Rules
- Always use imperative mood in prompts
- Always remove filler words
- Always use snippets over full files
- Always specify output constraints
- Always track token usage
Error Recovery Patterns
| Error Type | Detection | Recovery |
|---|
| Token limit exceeded | API error | Reduce context, retry |
| Quality degraded | Poor response | Add back necessary context |
| Cost over budget | Cost alert | Implement stricter limits |
Agent Prompt Pack
Bloat Detection Prompts
"Analyze this prompt for bloat:
- Identify filler words
- Find redundant phrases
- Check for unnecessary context
- Calculate token savings
- Suggest optimizations"
Prompt Optimization Prompts
"Optimize this prompt to reduce tokens:
- Use imperative mood
- Remove filler words
- Specify output format
- Add length constraints
- Maintain quality"
Context Optimization Prompts
"Optimize this context for AI:
- Use snippets over full files
- Remove irrelevant information
- Eliminate redundancy
- Focus on task-relevant content
- Track token savings"
Definition of Done
Bloat optimization is complete when:
Anti-patterns
- Verbose instructions: Long, wordy prompts
- Filler words: Unnecessary words
- Redundancy: Repeating information
- Full files: Including entire files when snippets suffice
- No constraints: Unlimited output length
- Preambles: "Here's what I did:" in responses
- Obvious comments: Comments stating the obvious
- Dead code: Commented-out code instead of deletion
Reference Links
Versioning & Changelog
v1.0.0 (2025-02-15)
- Initial release of Anti-Bloat Checklist skill
- Common bloat types (filler words, redundancy, unnecessary context)
- Prompt bloat detection
- Context bloat detection
- Response bloat prevention
- Documentation bloat
- Code comment bloat
- Configuration bloat
- Measurement and tracking
- Anti-bloat checklist
- Bloat audit process
- Token budget guidelines
- Quick wins