5 Bundle Strategies for Optimal AI Context
When working with AI assistants on code projects, the quality of your bundle directly impacts the quality of AI responses. Here are five battle-tested strategies for creating optimal bundles with m1f.
Quick Navigation
Full Context
For initial understanding and comprehensive reviews
Focused Feature
For specific features and bug fixes
Git Diff
For code reviews and incremental changes
Documentation First
For understanding and documentation tasks
Test-Driven
For test-focused development
1. The Full Context Strategy
Best for: Initial project understanding, architecture discussions, and comprehensive reviews.
# Using a preset configuration
m1f -s . -o context.txt --preset presets/ai-context.m1f-presets.yml
# Or using auto-bundle with a full preset
m1f auto-bundle full
This strategy includes everything except explicitly ignored files. Use it when:
- Starting a new AI conversation about your project
- Asking for architectural improvements
- Conducting security audits
- Requesting comprehensive documentation
Pro tip: Combine with --max-tokens
to ensure you stay within model limits:
# Check token count first
m1f-token-counter context.txt
# Then create a new bundle if needed with size limits
m1f -s . -o context.txt --max-file-size 100000
2. The Focused Feature Strategy
Best for: Feature development, bug fixes, and specific improvements.
# Create an input file list for focused bundling
echo "src/features/auth/" > auth-files.txt
echo "tests/auth/" >> auth-files.txt
# Bundle specific files
m1f -s . -i auth-files.txt -o auth-context.txt
Target specific areas of your codebase by including:
- The feature directory
- Related tests
- Configuration files
- Type definitions
This creates a focused context that helps AI understand the specific area you’re working on without overwhelming it with unrelated code.
3. The Changed Files Strategy
Best for: Code reviews, PR descriptions, and incremental changes.
# Get list of changed files
git diff --name-only main > changed-files.txt
# Bundle only changed files
m1f -s . -i changed-files.txt -o changes.txt
This strategy focuses on modified files, making it perfect for:
- Getting AI feedback on your changes
- Generating PR descriptions
- Understanding the impact of modifications
- Reviewing code before committing
Include uncommitted changes:
# Get both staged and unstaged changes
git diff --name-only HEAD > all-changes.txt
m1f -s . -i all-changes.txt -o changes.txt
4. The Documentation-First Strategy
Best for: Onboarding, API design, and project understanding.
# Use include-extensions for documentation files
m1f -s . -o docs-bundle.txt --include-extensions .md .txt
# Or create a preset for documentation
m1f -s . -o docs.txt --preset presets/documentation.m1f-presets.yml
Focus on high-level understanding by including:
- All markdown documentation
- Type definitions and interfaces
- Entry points and main files
- Configuration files
This strategy helps AI understand your project’s structure and purpose without getting lost in implementation details.
5. The Test-Driven Strategy
Best for: Test creation, debugging, and behavior understanding.
# Find all test files and bundle with source
find . -name "*.test.*" -o -name "*.spec.*" > test-files.txt
echo "src/" >> test-files.txt
m1f -s . -i test-files.txt -o test-context.txt
Include all tests alongside source code to help AI:
- Understand expected behavior
- Generate new tests
- Debug failing tests
- Suggest improvements based on test coverage
Combining Strategies
The real power comes from combining strategies. For example:
Feature Development + Tests
# Create a file list combining feature and test files
find src/features/payment -type f > payment-files.txt
find . -name "*payment*.test.js" >> payment-files.txt
git diff --name-only main >> payment-files.txt
# Bundle all related files
m1f -s . -i payment-files.txt -o payment-context.txt
Documentation + Recent Changes
# Get all markdown files and recent changes
find . -name "*.md" > docs-and-changes.txt
git diff --name-only HEAD >> docs-and-changes.txt
# Create bundle
m1f -s . -i docs-and-changes.txt -o docs-changes.txt
Token Optimization Tips
-
Check token count after creating bundles:
m1f-token-counter output.txt
-
Use verbose mode to see what will be processed:
m1f -s . -o output.txt --verbose
-
Exclude patterns that don’t add value:
m1f -s . -o output.txt --excludes "**/coverage/**" "**/*.map"
-
Use format wisely:
- XML format for Claude (most efficient)
- Markdown for visual reading
- Text for simple tools
Preset Customization
Create your own presets in .m1f.config.yml
:
presets:
feature-dev:
include:
- "src/features/**"
- "**/*.test.js"
- "docs/**/*.md"
exclude:
- "**/node_modules/**"
- "**/.git/**"
format: xml
max_tokens: 75000
Then use it:
m1f -s . -o output.txt --preset custom-presets.yml --preset-group feature-dev
Conclusion
The key to effective AI collaboration is providing the right context—not too much, not too little. These strategies help you achieve that balance, resulting in more accurate, helpful AI responses.
Experiment with different strategies for your use cases, and don’t forget to save your favorites as custom presets. Happy bundling!
Related Posts
The Irony of Claude Code: When AI Needs to Google Itself
A tale of how a multi-billion dollar AI needs to look up its own documentation online – and how m1f helps solve this existential crisis.
Introducing m1f: Feed Your AI the Whole Story
Learn how m1f revolutionizes AI context management by bundling your entire codebase into a single, AI-optimized file.