Enhance your coding experience in Visual Studio Code with rubberduck-vscode. This AI-powered extension offers code edits, explanations, generation, and error diagnosis using the OpenAI API, making development more efficient and intuitive.
claude install lgrammel/rubberduck-vscodehttps://github.com/rubberduck-ai/rubberduck-vscode
[{"step":"Install and Configure","description":"Install the rubberduck-vscode extension from the VS Code Marketplace. Configure your OpenAI API key in the extension settings (File > Preferences > Settings > Extensions > Rubberduck). Select your preferred model (e.g., GPT-4o) for optimal code-related tasks.","tips":"Use the latest stable version of VS Code. For enterprise users, set up a dedicated API key with usage limits to avoid unexpected costs."},{"step":"Select Code for Analysis","description":"Highlight the code you want to analyze or place your cursor within a function/file. Trigger the extension via the Command Palette (Ctrl+Shift+P) and select 'Rubberduck: Analyze Selection' or 'Rubberduck: Explain This'.","tips":"For large files, focus on specific functions or modules to get targeted feedback. Use the 'Rubberduck: Generate Tests' command to create unit tests for highlighted code."},{"step":"Review and Apply Changes","description":"Review the AI-generated suggestions in the 'Rubberduck' panel. Accept or modify changes directly in the editor. The extension can auto-apply fixes (e.g., for syntax errors) or provide inline comments for manual review.","tips":"Enable 'Auto-Apply Fixes' in settings for minor issues like formatting. For complex changes, review the diff in the 'Source Control' panel before committing."},{"step":"Iterate and Validate","description":"Run your test suite or manual checks to validate the changes. Use 'Rubberduck: Explain This' to get a detailed breakdown of the modified code's logic or performance implications.","tips":"For performance-critical code, ask rubberduck-vscode to suggest optimizations (e.g., 'How can I improve the time complexity of this function?'). Use the 'Rubberduck: Debug This' command to step through AI-generated fixes."},{"step":"Document and Share","description":"Use the extension's 'Generate Docstring' command to add or update documentation for functions. Share the AI's explanations with your team via the 'Copy Explanation to Clipboard' feature.","tips":"For collaborative projects, enable 'Share Explanations' in settings to generate a summary of changes for pull requests. Use the 'Rubberduck: Compare Implementations' command to evaluate alternative solutions."}]
Generate code snippets based on specific user prompts to accelerate development.
Diagnose and suggest fixes for coding errors to streamline debugging efforts.
Provide clear explanations for complex code segments, enhancing understanding and learning.
Facilitate real-time coding assistance through chat, allowing for immediate feedback and support.
claude install lgrammel/rubberduck-vscodegit clone https://github.com/lgrammel/rubberduck-vscodeCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Use the rubberduck-vscode extension in Visual Studio Code to [TASK]. Focus on [LANGUAGE/FRAMEWORK] and ensure the solution follows [STYLE_GUIDE]. Provide the code changes directly in the editor and explain the reasoning behind each modification. If errors are detected, diagnose them and suggest fixes with context about why they occurred.
```python
# Original code in main.py (line 42-48)
def calculate_discount(price: float, discount_rate: float) -> float:
if discount_rate > 1:
return price # Bug: Should validate discount_rate <= 1.0
return price * (1 - discount_rate)
# Fixed code (auto-applied by rubberduck-vscode)
def calculate_discount(price: float, discount_rate: float) -> float:
if not 0 <= discount_rate <= 1:
raise ValueError("Discount rate must be between 0 and 1")
return price * (1 - discount_rate)
```
**Diagnosis:**
The original code failed to validate the `discount_rate` parameter, allowing invalid values like 1.5 (150%) to pass through. This could lead to negative prices or incorrect calculations in downstream systems.
**Explanation of Fixes:**
1. **Input Validation:** Added explicit bounds checking (`0 <= discount_rate <= 1`) to prevent invalid inputs.
2. **Error Handling:** Replaced silent failure with a `ValueError` to fail fast and provide clear feedback.
3. **Type Safety:** Maintained type hints for better IDE support and maintainability.
**Next Steps:**
- Run unit tests to verify the fix handles edge cases (e.g., `discount_rate = 0`, `discount_rate = 1`).
- Update any documentation or comments referencing the old behavior.
- Consider adding logging for invalid inputs in production environments.
**Performance Impact:** Minimal—validation adds negligible overhead for typical use cases.Automate your customer service.
Create Beautiful Branded Deliverables. Ship Professionally. Repeat.
Advanced foundation models via API and ChatGPT
Orchestrate workloads with multi-cloud support, job scheduling, and integrated service discovery features.
CI/CD automation with build configuration as code
Enhance performance monitoring and root cause analysis with real-time distributed tracing.
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan