Context Command Guide
The context command generates comprehensive context for LLM interactions.
Basic Usage
bash
# Generate context for current directory
mkforge context
# Generate context for specific directory
mkforge context ./my-project
# Generate with specific output file
mkforge context -o project-context.mdCommand Options
bash
Options:
-o, --output string output file (default is ./context.md)
-s, --structure-only only include file structure
-c, --content-only only include file contents
-f, --format string output format (md or txt)
--max-files int maximum number of files to process
--ignore strings additional patterns to ignoreGenerated Context Structure
The generated context includes:
Metadata Header
markdown<!-- MKFORGE-CONTEXT { "generated_by": "mkforge", "generated_at": "2025-01-19T10:38:56.482006-05:00", "version": "v0.1.2", "checksum_source": "0d1c6598..." } MKFORGE-CONTEXT -->Project Information
markdown# Project Information Type: go Git Branch: main Git Status: cleanFile Structure
markdown# File Structure.github/workflows/deploy.yml .gitignore cmd/root.go internal/config/config.go
File Contents
markdown# File Contents ## cmd/root.go ```go package cmd ...
Features
Project Type Detection
MKForge automatically detects project types based on common files:
- Node.js:
package.json - Go:
go.mod - Python:
requirements.txt,setup.py - Ruby:
Gemfile - PHP:
composer.json - Rust:
Cargo.toml - Java:
pom.xml
Smart File Filtering
The context generator automatically:
- Excludes binary files
- Respects size limits
- Follows ignore patterns
- Skips non-text content
Git Integration
When in a Git repository, includes:
- Current branch name
- Working directory status (clean/dirty)
- Respects
.gitignorepatterns
Incremental Updates
MKForge maintains checksums of source files and only regenerates context when:
- Files have been modified
- Files have been added/removed
- Configuration has changed
Best Practices
1. Structure Management
bash
# Generate only structure for large projects
mkforge context --structure-only
# Generate only content for specific files
mkforge context --content-only2. File Selection
bash
# Limit number of files
mkforge context --max-files 50
# Add custom ignore patterns
mkforge context --ignore "tests/*" --ignore "*.tmp"3. Output Control
bash
# Use text format for simpler output
mkforge context -f txt
# Specify custom output location
mkforge context -o docs/project-context.md4. Performance Tips
- Start with
--structure-onlyfor large projects - Use appropriate
max_file_sizein config - Configure relevant ignore patterns
- Use incremental updates
Common Issues
Large Projects
For large projects:
- Use
--structure-onlyinitially - Adjust
max_files_to_includein config - Add specific ignore patterns
- Consider using separate contexts for different parts
Binary Files
If binary files are being included:
- Check excluded extensions in config
- Add specific ignore patterns
- Use
--max-filesto limit processing
Memory Usage
For memory-intensive projects:
- Reduce
max_file_size - Limit number of files
- Use more specific ignore patterns
- Split into multiple contexts
