Dev Tools // // 4 min read

🎯 ContextCraft: The Plugin That Makes AI Understand Your Code Better

balakumar Senior Software Engineer

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.

IntelliJ Plugin

GoLand Plugin

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

For IntelliJ IDEA

git clone https://github.com/balakumardev/ContextCraft

For GoLand

git clone https://github.com/balakumardev/ContextCraft-GoLand

Installation Guide

IntelliJ Plugin

  1. Build the plugin:

    cd intellij-related-files-copier
    ./gradlew buildPlugin
  2. Install:

    • Settings → Plugins → ⚙️ → "Install Plugin from Disk..."
    • Select ZIP from build/distributions/

GoLand Plugin

  1. Build the plugin:

    cd goland-related-files-copier
    ./gradlew buildPlugin
  2. 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
  1. 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
  2. Claude-3 Opus (200K tokens)

    • Great for large projects
    • Handles multiple file contexts easily
    • Recommended for comprehensive codebase analysis
  3. GPT-4o (128K tokens)

    • Good for medium to large projects
    • Handles most use cases effectively
  4. Claude-3 Sonnet (100K tokens)

    • Suitable for medium-sized projects
    • May require content splitting for larger codebases
  5. GPT-4 (32K tokens)

    • Best for smaller files
    • May need content trimming for larger contexts

Tips for Large Contexts

  1. Start with core files first
  2. Split related files into logical groups
  3. Prioritize direct dependencies over indirect ones
  4. 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

  1. Test Generation

    • Complete context for accurate test cases
    • Full coverage of edge cases
  2. Code Reviews

    • Better understanding of changes
    • Impact analysis across files
  3. Documentation

    • Comprehensive API docs
    • Relationship documentation
  4. Refactoring

    • Safe refactoring suggestions
    • Cross-file impact analysis

Future Roadmap

  1. Smart Content Trimming

    • Intelligent context reduction
    • Priority-based file selection
  2. LLM-Specific Formatting

    • Optimized output for different LLMs
    • Custom templates
  3. Integration Features

    • Direct LLM API integration
    • Context management tools

Best Practices

  1. Context Management

    • Use larger context LLMs for complex projects
    • Split content for smaller context LLMs
    • Focus on relevant files first
  2. 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.