AI Context Optimizer
AI Context Optimizer is a VS Code extension that helps developers generate higher-quality AI prompts from real workspace context instead of manual copy/paste snippets.
It is built for enterprise and large-repository workflows where relevance, token efficiency, and safety matter. The extension analyzes your workspace, builds semantic/dependency context, ranks likely-relevant files, and generates an AI-ready prompt you can use with GitHub Copilot, ChatGPT, Claude, Gemini, or other LLM chat interfaces.
Why teams use it
- Reduces time spent collecting files and code context manually.
- Improves prompt quality and consistency across developers.
- Helps control token usage with budget-aware context assembly.
- Adds local safety checks for sensitive data before sharing prompts externally.
Supported AI assistants
- GitHub Copilot
- ChatGPT
- Claude
- Gemini
- Other LLM tools that accept plain text/Markdown prompts
The generated prompt format is AI-platform independent.
✨ Features
🧠 AI Prompt Optimization
- Optimizes raw developer prompts with a validation pipeline.
- Includes quality analysis before/after optimization when enabled.
🎯 Intent Analysis
- Performs rule-based intent analysis on prompt text.
- Extracts intent signals, technologies, operations, and entities used downstream in ranking.
- Derives keyword signals from intent analysis and prompt content.
- Uses these signals in candidate generation and relevance scoring.
🔗 Dependency-aware Context Ranking
- Builds a dependency graph and applies dependency-aware ranking.
- Scores candidates using keyword, symbol, file-name, config, recency, and dependency signals.
📦 Workspace Context Assembly
- Assembles a structured context package from ranked files.
- Includes Markdown/JSON context export support internally.
📏 Smart Context Budget
- Enforces token budget limits during context assembly.
- Prioritizes higher-value context when budget is constrained.
⚡ Token Reduction
- Uses smart-context generators and section prioritization to reduce output size.
- Includes token counting command for selection/file analysis.
📊 Dashboard
- Provides a webview dashboard with optimization history and pipeline summaries.
- Displays workspace, indexing, dependency, pipeline, and Copilot workflow state.
✅ Prompt Quality Analysis
- Optional quality analyzer evaluates clarity/structure/specificity/context signals.
- Integrated into optimization workflow.
🔐 Sensitive Data Detection
- Detects common secret patterns (API keys, tokens, passwords, connection strings, etc.).
- Optional auto-masking behavior.
🕘 Prompt History
- Stores prompt/optimization history in extension global state when enabled.
- Search and clear actions are available in the dashboard.
📋 Automatic Clipboard Integration
- One-click prompt generation supports automatic clipboard copy.
- Includes explicit command to copy last generated prompt.
🧩 Multiple Prompt Styles
- Prompt generation supports formatter-driven styles.
- Implemented formatter styles:
Balanced, Minimal, Detailed, Debug, ArchitectureReview.
CodeReview and BugFix appear in configuration/options, but currently fall back to the default formatter when a dedicated formatter is not registered.
📤 Export Support
- Export generated prompt as
markdown, json, or plaintext.
🏗 Architecture
User Prompt
↓
Intent Analysis
↓
Keyword Extraction
↓
Candidate Generation
↓
Dependency-aware Ranking
↓
Context Assembly
↓
Markdown Prompt Generation
↓
Automatic Clipboard Copy
↓
GitHub Copilot (or other AI assistant)
📸 Screenshots
Dashboard
(Add Screenshot)
Prompt Generation
(Add Screenshot)
Intent Analysis
(Add Screenshot)
📦 Installation
Install from VS Code Marketplace
- Open VS Code.
- Open Extensions (
Ctrl+Shift+X / Cmd+Shift+X).
- Search for AI Context Optimizer.
- Select Install.
Marketplace listing: https://marketplace.visualstudio.com/items?itemName=msinha.ai-context-optimizer
Install from VSIX
- Download the
.vsix package.
- In VS Code, open Extensions view.
- Use the
... menu and choose Install from VSIX....
- Select the downloaded file.
🚀 Quick Start
- Open a workspace folder in VS Code.
- Run AI Context Optimizer: Generate Copilot Prompt.
- Enter your task prompt.
- Let the extension validate/build index and dependency graph as needed.
- Paste the generated prompt into GitHub Copilot (or another supported assistant).
⌨️ Commands
| Command |
Description |
AI Context Optimizer: Generate Copilot Prompt |
One-click flow to generate a Copilot-ready prompt from workspace context. |
AI Context Optimizer: Generate Copilot Prompt (Advanced) |
Same as above with explicit style selection. |
AI Context Optimizer: Optimize Prompt |
Optimizes a raw prompt using validation, quality, and safety steps. |
AI Context Optimizer: Open Dashboard |
Opens dashboard webview with history and pipeline summaries. |
AI Context Optimizer: Export Prompt |
Exports the latest generated prompt. |
AI Context Optimizer: Count Tokens in Selection or File |
Counts estimated tokens for selected text or active file. |
AI Context Optimizer: Analyze Workspace |
Runs workspace analysis summary. |
AI Context Optimizer: Build Context for Prompt |
Builds context package for a prompt. |
AI Context Optimizer: Build Semantic Index |
Builds semantic index for workspace files. |
AI Context Optimizer: Build Dependency Graph |
Builds dependency graph from indexed symbols/files. |
AI Context Optimizer: Assemble Context Package |
Assembles context package from ranked candidates. |
AI Context Optimizer: Run Candidate Pipeline |
Runs candidate generation + relevance stages. |
AI Context Optimizer: Run AI Pipeline |
Runs orchestrated AI relevance pipeline end-to-end. |
AI Context Optimizer: Preview Copilot Prompt |
Opens preview of last generated Copilot prompt. |
AI Context Optimizer: Copy Copilot Prompt to Clipboard |
Copies last generated Copilot prompt to clipboard. |
Note: Some developer-oriented commands are contributed but hidden from the default Command Palette menu visibility.
⚙️ Configuration
| Setting |
Default |
Description |
aiContextOptimizer.enableSensitiveScanner |
true |
Scan prompts for sensitive data before optimization. |
aiContextOptimizer.enableQualityAnalyzer |
true |
Analyze prompt quality before and after optimization. |
aiContextOptimizer.enablePromptHistory |
true |
Persist optimization history across VS Code sessions. |
aiContextOptimizer.autoMaskSensitiveData |
false |
Automatically mask detected sensitive values. |
aiContextOptimizer.autoCopyPreparedPrompt |
true |
Auto-copy prepared prompt after prepare workflow. |
aiContextOptimizer.showDashboardAfterOptimization |
false |
Open dashboard automatically after optimization. |
aiContextOptimizer.statusBarDurationSeconds |
30 |
Status bar result visibility duration in seconds (0 = permanent). |
aiContextOptimizer.copilot.defaultPromptStyle |
Balanced |
Default style for generated Copilot prompts. |
aiContextOptimizer.copilot.defaultExportFormat |
markdown |
Default export format (markdown, json, plaintext). |
aiContextOptimizer.copilot.defaultTokenBudget |
32000 |
Default token budget for generated prompts (minimum 1000). |
aiContextOptimizer.copilot.autoCopyPrompt |
true |
Auto-copy generated prompt in one-click Copilot workflow. |
aiContextOptimizer.copilot.showPromptPreview |
true |
Show prompt preview after generation. |
aiContextOptimizer.copilot.autoOpenChat |
true |
Attempt to focus Copilot Chat automatically after generation. |
aiContextOptimizer.copilot.showCompletionNotification |
true |
Show completion summary notification after generation. |
aiContextOptimizer.showWelcomeOnFirstRun |
true |
Show onboarding welcome message on first activation. |
🤖 Supported AI Assistants
- GitHub Copilot
- ChatGPT
- Claude
- Gemini
- Other LLM assistants that accept generated prompts
Prompts are generated as structured text/Markdown and are not tied to one AI vendor.
🧪 Example Workflow
Developer Prompt
↓
Optimized Prompt
↓
GitHub Copilot
↓
Better AI Response
AI Context Optimizer is designed around local analysis pipelines and token-aware context construction.
- Uses dependency-aware relevance ranking to prioritize meaningful files.
- Applies adaptive token budgeting during context assembly.
- Reduces context size through smart-context generation and section prioritization.
- Supports enterprise-scale workspaces through workspace indexing and graph-based analysis.
🔐 Privacy
- Source code is processed locally inside VS Code by this extension.
- Source code does not leave your machine unless you manually submit generated content to an external AI assistant.
- Clipboard access is used to copy generated prompts when copy options are enabled.
- No telemetry pipeline is implemented in the extension codebase.
- No hidden background uploads are performed by the extension.
📋 Requirements
- VS Code:
^1.125.0
- Operating systems: Windows, macOS, Linux (where supported by VS Code)
🗺 Roadmap
Planned items:
- Explainability Engine enhancements
- Smart Context Generator enhancements
- Enhanced GitHub Copilot integration
- Workspace Intelligence improvements
- AI Recommendation capabilities
Roadmap items above are future work and not presented as currently shipped features.
🤝 Contributing
Contributions are welcome.
- Fork the repository.
- Create a feature branch.
- Add or update tests where applicable.
- Submit a pull request with a clear description.
Repository: https://github.com/msinha53/ai-context-optimizer
📄 License
MIT License. See LICENSE.
🆘 Support
📝 Changelog
See CHANGELOG.md.