AI & ML // // 6 min read

PromptForge: Eliminating LLM Hallucinations With Perfect Context

Bala Kumar Senior Software Engineer

The Context Conundrum

As developers, we've all been there. You're stuck on a complex problem, so you turn to ChatGPT or another LLM for help. You carefully copy your code, paste it into the chat, and wait for the magic to happen.

But instead, you get:

"I'll need to see the related classes to understand this better."

So you find another file, copy it, paste it...

"I still don't have enough context. Can you show me how this interfaces with your service layer?"

And the dance continues. Copy, paste, explain, repeat. It's a tedious cycle that wastes precious development time.

While IDE-integrated AI assistants like GitHub Copilot and JetBrains AI are making strides, they often make opaque decisions about what context to include, constrained by token limits and cost considerations. Sometimes you just want full control over the context you provide to your AI assistant.

That's why I built PromptForge.

Introducing PromptForge: Context-Rich Prompts with a Single Click

PromptForge is an IntelliJ plugin that bridges the gap between your IDE and any LLM of your choice. It's designed with a simple philosophy: give your LLM the full context it needs with minimal effort.

PromptForge Menu

With PromptForge, the workflow becomes beautifully simple:

  1. Right-click on a file in your IDE
  2. Select a PromptForge action from the context menu
  3. The plugin automatically collects all related context
  4. Paste the result into your favorite LLM
  5. Get accurate, contextual responses the first time

No more back-and-forth. No more missing context. Just right-click, paste, and get answers.


Why I Built PromptForge

As a developer who regularly uses LLMs to accelerate my workflow, I was frustrated by the constant context-gathering dance. I wanted something that would:

  1. Preserve my control over which LLM I use
  2. Automatically gather context from related files
  3. Format prompts optimally for different tasks
  4. Work seamlessly within my existing IDE

Most importantly, I wanted something that wouldn't require me to share my entire codebase with a third-party service or be limited by token windows. PromptForge lets me decide exactly what context to include, then take that to any LLM I choose.

The Secret Sauce: Intelligent Context Gathering

What makes PromptForge special is how it intelligently gathers context from your codebase:

  • Analyzes imports and references to find related files
  • Follows inheritance hierarchies to include parent classes and implementations
  • Respects your configuration for depth and scope of context
  • Prunes irrelevant content to focus on what matters
  • Formats everything into an optimized prompt

All of this happens automatically when you right-click and select a PromptForge action.

Task-Specific Actions for Maximum Productivity

PromptForge isn't just about gathering context—it's about formatting that context into the optimal prompt for your specific task:

🧪 Generate Tests

Perfect for TDD or adding tests to existing code. PromptForge detects if you're working with a new file or making changes to an existing one, then formats the prompt accordingly:

  • For new files: "Create a comprehensive test suite for this class"
  • For modified files: "Generate test methods for these specific changes"

It even includes your existing test file for context if you're modifying code!

📝 Explain Code

When you're staring at a complex piece of code thinking "what does this even do?" PromptForge gathers all the context needed for an LLM to provide a comprehensive explanation.

❓ Ask Questions

Have a specific question about your code? This action lets you ask it while providing all the context the LLM needs to answer correctly.

🔄 Make Changes

Need to implement a feature or fix a bug? PromptForge helps you get accurate suggestions based on your entire codebase's context.

📋 Copy with Context

For power users who want to craft their own prompts but still need the related files and context.

Configurable to Your Needs

PromptForge is highly configurable to match your workflow:

  • Control how deep to search for related files
  • Exclude specific packages from context gathering
  • Customize prompt templates for each action
  • Enable or disable smart content pruning
  • Include or exclude decompiled classes

PromptForge Settings

Real-World Example: Generating Tests for a Complex Service

Let me walk you through a real example of how PromptForge has saved me hours of work.

I was working on a complex service class with multiple dependencies and interfaces. Writing tests for it manually would have been time-consuming and error-prone.

With PromptForge, I simply:

  1. Right-clicked on my service class
  2. Selected "Generate Tests" from the PromptForge menu
  3. Pasted the generated prompt into ChatGPT
  4. Received a complete test class with mocks for all dependencies, edge cases covered, and proper assertions

The best part? I didn't have to manually gather any context. PromptForge automatically included:

  • The service class itself
  • All interfaces it implemented
  • All dependency classes it used
  • Related utility classes

The result was a comprehensive test suite that I could review, refine, and integrate into my codebase in minutes instead of hours.

The Future of PromptForge

This is just the beginning for PromptForge. I'm actively working on new features:

  • Support for more languages beyond Java
  • Additional specialized prompt templates
  • Integration with more IDEs in the JetBrains family
  • Performance optimizations for very large codebases
  • Community-contributed prompt templates

Get Started with PromptForge Today

PromptForge is available as an IntelliJ plugin. While it's not yet on the JetBrains Marketplace, you can easily install it manually:

  1. Download the latest release ZIP from GitHub
  2. In IntelliJ IDEA, go to SettingsPlugins
  3. Click the gear icon (⚙️) and select Install Plugin from Disk...
  4. Choose the downloaded ZIP file
  5. Restart IntelliJ IDEA when prompted

Requirements

  • IntelliJ IDEA 2023.1 or later
  • Java 17 or later
  • Git installed and configured (for modified file detection)

Join the PromptForge Community

PromptForge is open source and community-driven. I'd love for you to get involved:

  • Star the GitHub repository
  • Report issues or suggest features
  • Contribute code or documentation
  • Share your custom prompt templates

Conclusion: A New Era of LLM-Assisted Development

PromptForge represents a new approach to working with LLMs in your development workflow—one that respects your control, your privacy, and your time.

By bridging the gap between your IDE and your LLM of choice, PromptForge eliminates the tedious context-gathering dance and lets you focus on what matters: writing great code.

Give it a try today, and experience the difference that proper context makes in your AI-assisted development workflow.