🎯 ContextCraft: The Plugin That Makes AI Understand Your Code Better
Introduction
In today's AI-driven development landscape, providing comprehensive context to Large Language Models (LLMs) is crucial. I've developed two plugins - one for IntelliJ IDEA and another for GoLand - that make this process seamless by copying related files with their dependencies.
⚠️ Important Note: These plugins can generate large amounts of text content. It's recommended to use LLMs with large context windows (like Gemini with 2M tokens, Claude-3 Opus with 200K tokens or GPT-4o with 128K tokens) for optimal results.
The Problem
When working with LLMs, providing incomplete context can lead to:
- Hallucinated code suggestions
- Failed test cases
- Incorrect assumptions about dependencies
- Misaligned code proposals
The Solution: Related Files Copier Plugins
For IntelliJ IDEA
git clone https://github.com/balakumardev/ContextCraft
For GoLand
git clone https://github.com/balakumardev/ContextCraft-GoLand
Installation Guide
IntelliJ Plugin
-
Build the plugin:
cd intellij-related-files-copier ./gradlew buildPlugin -
Install:
- Settings → Plugins → ⚙️ → "Install Plugin from Disk..."
- Select ZIP from
build/distributions/
GoLand Plugin
-
Build the plugin:
cd goland-related-files-copier ./gradlew buildPlugin -
Install:
- Settings → Plugins → ⚙️ → "Install Plugin from Disk..."
- Select ZIP from
build/distributions/
Features Comparison
| Feature | IntelliJ Plugin | GoLand Plugin |
|---|---|---|
| Source Files | .java, .kt, .scala, .groovy | .go |
| Package Detection | Java package system | Go modules |
| Import Resolution | Java/Kotlin imports | Go imports |
| Context Menu Location | Editor & Project View | Editor & Project View |
Context Size Considerations
Large Context Generation
The plugins can generate significant amounts of text when dealing with:
- Complex class hierarchies
- Multiple interdependent files
- Large packages
Recommended LLMs by Context Size
-
Google Gemini (2M tokens)
- Ideal for extremely large projects
- Can handle entire package contexts
- Perfect for monorepo analysis
- Best for comprehensive system understanding
- No need to split content in most cases
-
Claude-3 Opus (200K tokens)
- Great for large projects
- Handles multiple file contexts easily
- Recommended for comprehensive codebase analysis
-
GPT-4o (128K tokens)
- Good for medium to large projects
- Handles most use cases effectively
-
Claude-3 Sonnet (100K tokens)
- Suitable for medium-sized projects
- May require content splitting for larger codebases
-
GPT-4 (32K tokens)
- Best for smaller files
- May need content trimming for larger contexts
Tips for Large Contexts
- Start with core files first
- Split related files into logical groups
- Prioritize direct dependencies over indirect ones
- Consider using LLM-specific code block formats
Technical Implementation
IntelliJ Plugin
- Built with Kotlin
- Uses IntelliJ Platform SDK
- Handles JVM language ecosystem
GoLand Plugin
- Built with Go
- Uses GoLand SDK
- Specialized for Go module system
Use Cases
-
Test Generation
- Complete context for accurate test cases
- Full coverage of edge cases
-
Code Reviews
- Better understanding of changes
- Impact analysis across files
-
Documentation
- Comprehensive API docs
- Relationship documentation
-
Refactoring
- Safe refactoring suggestions
- Cross-file impact analysis
Future Roadmap
-
Smart Content Trimming
- Intelligent context reduction
- Priority-based file selection
-
LLM-Specific Formatting
- Optimized output for different LLMs
- Custom templates
-
Integration Features
- Direct LLM API integration
- Context management tools
Best Practices
-
Context Management
- Use larger context LLMs for complex projects
- Split content for smaller context LLMs
- Focus on relevant files first
-
Performance Optimization
- Regular cleanup of clipboard content
- Monitor memory usage
- Use selective copying when possible
Get Involved
Both projects are open-source and welcome contributions:
For IntelliJ Plugin
git clone https://github.com/balakumardev/ContextCraft
For GoLand Plugin
git clone https://github.com/balakumardev/ContextCraft-GoLand
Conclusion
These plugins significantly improve the LLM-assisted development workflow by providing comprehensive context. Just remember to:
- Choose appropriate LLMs based on your context size
- Monitor clipboard content size
- Split content when necessary
- Consider the relationship depth needed
The tools are simple yet powerful additions to any developer's toolkit, especially when working with AI assistants.
Remember to check compatibility with your IDE versions and feel free to contribute to either project!
Note: For extremely large projects, consider implementing a systematic approach to breaking down the context into manageable chunks while maintaining logical coherence.