AI Code Assistance
ThinkCode leverages advanced artificial intelligence to enhance your coding workflow, increase productivity, and reduce cognitive load. This guide covers the core AI assistance features and how to best utilize them.
Understanding AI Code Assistance
ThinkCode's AI code assistance helps you write, understand, and improve code through context-aware suggestions and intelligent guidance.
Key Capabilities
Code Generation
Transform natural language or comments into working code:
From Natural Language
Use the Think Panel to generate code from descriptions:
- Open the Think Panel with
Ctrl+Shift+T
(Cmd+Shift+T
on macOS) - Describe what you need: "Create a React hook that manages a paginated API request with error handling"
- Review and apply the generated code
From Comments
Write descriptive comments and get code generated inline:
After typing your comment, press Alt+Enter
(Option+Enter
on macOS) to generate the implementation.
Multi-File Generation
For larger features that span multiple files:
- Open the Think Panel
- Describe the feature: "Create a user authentication system with login, registration, and password reset"
- The AI will analyze your project structure and suggest implementations across multiple files
Intelligent Code Completion
ThinkCode provides context-aware completions as you type:
Inline Completions
As you write code, ThinkCode suggests completions based on:
- Current file context
- Project patterns and conventions
- Related files and imports
- Type information
- Documentation
Accept suggestions with Tab
or dismiss with Esc
.
Completion Controls
Fine-tune your completion experience:
Action | Shortcut |
---|---|
Accept full suggestion | Tab |
Accept word by word | Ctrl+Right / Cmd+Right |
Next suggestion | Alt+] / Option+] |
Previous suggestion | Alt+[ / Option+[ |
Trigger suggestion manually | Alt+\ / Option+\ |
Dismiss suggestion | Esc |
Completion Settings
Adjust the frequency and behavior of completions in Settings:
Code Understanding and Explanations
Get instant explanations for complex code:
Explain Code
To explain selected code:
- Select the code you want to understand
- Right-click and choose "Think: Explain Selection" or use
Ctrl+Alt+E
(Cmd+Option+E
on macOS) - View the explanation in the Think Panel
Example explanation for complex regex:
Understanding Error Messages
Get plain-language explanations for errors:
- Hover over the error squiggle
- Click "Explain Error" in the hover tooltip
- View the explanation and suggested fix
Code Refactoring and Improvement
Improve existing code with AI-assisted refactoring:
Refactor Selection
To refactor code:
- Select the code to refactor
- Right-click and choose "Think: Refactor Selection" or use
Ctrl+Alt+R
(Cmd+Option+R
on macOS) - View suggested improvements in the Think Panel
- Apply changes selectively or all at once
Optimization Suggestions
Get performance optimization suggestions:
- Select code to optimize
- Right-click and choose "Think: Optimize Selection"
- Review suggested optimizations with explanations of potential performance improvements
Code Quality Improvements
Improve code quality with AI suggestions:
- Select code to improve
- Use the Command Palette (
Ctrl+Shift+P
/Cmd+Shift+P
) to run "Think: Improve Code Quality" - Review suggestions for:
- Better naming
- More maintainable structure
- Improved error handling
- Enhanced readability
- Proper documentation
Advanced Features
Language-Specific Assistance
ThinkCode provides specialized assistance for different programming languages:
TypeScript/JavaScript
- Type inference and suggestions
- React component generation
- Modern ES6+ patterns
- Framework-specific suggestions (React, Angular, Vue, etc.)
Python
- PEP 8 compliant suggestions
- Library-specific code patterns (Django, Flask, NumPy, etc.)
- Type hints and documentation
Other Languages
ThinkCode supports numerous languages with varying levels of assistance:
- Java
- C#
- Go
- Rust
- PHP
- Ruby
- And many more
Interactive Code Generation
For complex generation tasks, engage in an interactive process:
- Start with a high-level request
- Review the initial generation
- Ask follow-up questions to refine
- Provide feedback on what works and what doesn't
- Guide the AI to your desired implementation
Example conversation:
AI Unit Test Generation
Generate comprehensive test suites:
- Select the code to test
- Use the Command Palette to run "Think: Generate Tests"
- Choose your testing framework (Jest, Mocha, Pytest, etc.)
- Review and customize the generated tests
Code Transformation
Transform code between different styles or paradigms:
- Select the code to transform
- Use the Command Palette to run "Think: Transform Code"
- Choose a transformation type:
- Convert to async/await from Promises
- Refactor class to functional components
- Convert to TypeScript from JavaScript
- And many more
AI-Generated Documentation
Generate comprehensive documentation for your code:
- Select the code to document
- Use
Ctrl+Alt+D
(Cmd+Option+D
on macOS) - Choose documentation style (JSDoc, docstrings, etc.)
- Review and customize the generated documentation
Best Practices
Effective Prompting
Get better results with these prompting techniques:
- Be specific: Provide clear, detailed instructions
- Add context: Mention frameworks, patterns, or requirements
- Iterative refinement: Start general, then refine with follow-up requests
- Use examples: Show examples of the patterns you prefer
Verifying AI Code
Always review AI-generated code:
- Understand the code: Make sure you understand what the AI has generated
- Test thoroughly: Verify functionality with appropriate tests
- Check edge cases: Consider boundary conditions and error scenarios
- Review for security: Look for potential security issues
- Optimize if needed: Make performance improvements where necessary
Customizing AI Behavior
Adjust ThinkCode's AI to match your preferences:
- AI Settings: Customize in the settings under "Think" section
- Context Controls: Adjust what files the AI considers
- AI Roles: Switch between different AI personalities (Developer, Architect, Reviewer, etc.)
- Language-Specific Settings: Configure behavior for specific languages
Troubleshooting
Improving Poor Suggestions
If you're getting unhelpful suggestions:
- Provide more context: Give additional information about your project and goals
- Use more specific prompts: Detail exactly what you need
- Adjust AI settings: Change the suggestion frequency or model
- Check file visibility: Ensure relevant files are available in the workspace
- Update AI model: Check if you're using the latest AI model
Managing Resource Usage
If AI features are causing performance issues:
- Adjust suggestion frequency in settings
- Limit the context size
- Use lighter AI models
- Close unused files
Next Steps
To further enhance your AI coding experience:
- Explore AI Sandbox Debugging for intelligent debugging assistance
- Learn about Session Management to save and restore your AI context
- Discover Software Engineering features for larger project management
Pro Tip
Create a file called .thinkcode/prompts.json
in your project root to save commonly used prompts for your team. This helps maintain consistency when using AI assistance across your project.