Sypha AI Docs
FeaturesCommands and shortcuts

Code Commands

Sypha's code commands integrate AI assistance directly within your editor, enabling you to interact with your code without interrupting your workflow. Through a simple right-click, you can send code to Sypha, and via the lightbulb menu, you can correct errors, obtain explanations, or enhance your code.

Available Code Commands

When interacting with code in your editor, Sypha commands can be accessed through two methods:

Right-Click Context Menu

When you right-click on selected code, you'll find:

Right Click Menu

Add to Sypha

The "Add to Sypha" command transfers your selected code to the Sypha chat panel. This is ideal for:

  • Asking questions about particular code snippets
  • Requesting enhancements or optimizations
  • Obtaining explanations of complex logic

When utilizing this command, Sypha automatically includes:

  • The file path (as a file mention)
  • The selected code with appropriate formatting
  • The programming language for precise syntax highlighting

Lightbulb Menu (Code Actions)

When a lightbulb icon appears in your editor, click it to access these Sypha commands:

Lightbulb Menu

Fix with Sypha

The "Fix with Sypha" command displays in the lightbulb menu when your code contains errors or warnings. This command:

  1. Captures the selected code
  2. Identifies the errors or warnings from VSCode's diagnostics
  3. Sends both to Sypha with a request to resolve the issues
  4. Delivers a solution that addresses the specific problems

This is exceptionally useful for rapidly resolving syntax errors, linter warnings, or type issues without manually describing the problem.

Explain with Sypha

The "Explain with Sypha" command assists you in understanding complex code. When you select code and use this command from the lightbulb menu, Sypha:

  1. Analyzes the selected code
  2. Delivers a clear explanation of what the code accomplishes
  3. Breaks down complex logic into comprehensible parts
  4. Highlights significant patterns or techniques employed

Improve with Sypha

The "Improve with Sypha" command assists you in enhancing your code. When you select code and use this command from the lightbulb menu, Sypha:

  1. Analyzes the selected code for potential enhancements
  2. Suggests optimizations, refactorings, or superior practices
  3. Explains the reasoning behind the suggested modifications
  4. Provides improved code that preserves the original functionality

How to Use Code Commands

Utilizing Sypha's code commands is straightforward:

For Right-Click Commands:

  1. Select the code you wish to work with
  2. Right-click to open the context menu
  3. Choose "Add to Sypha"
  4. View the result in the Sypha chat panel

For Lightbulb Menu Commands:

  1. Select the code you wish to work with
  2. Look for the lightbulb icon appearing in the editor gutter
  3. Click the lightbulb to reveal available actions
  4. Choose the appropriate Sypha command (Fix, Explain, or Improve)
  5. View the result in the Sypha chat panel

After utilizing any command, you can:

  • Ask follow-up questions
  • Request modifications to the solution
  • Apply the changes back to your code

How It Works Under the Hood

When you employ a code command, here's what occurs behind the scenes:

  1. Code Selection: The extension captures your selected code and its context

  2. Metadata Collection: Sypha collects important metadata:

    • File path and name
    • Programming language
    • Any associated diagnostics (errors/warnings)
    • Surrounding code context when applicable
  3. Command Processing:

    • For "Add to Sypha," the code is formatted and transmitted to the chat panel
    • For "Fix with Sypha," the code and diagnostics are analyzed and a fix is generated
    • For "Explain with Sypha," the code is analyzed to deliver a clear explanation
    • For "Improve with Sypha," the code is analyzed for potential optimizations and enhancements
  4. Integration with Chat: The results display in the Sypha chat panel, where you can:

    • See the AI's response
    • Ask follow-up questions
    • Apply suggested changes

This seamless integration between your editor and Sypha's AI capabilities facilitates obtaining assistance without disrupting your coding flow.

Tips for Effective Use

  • Select complete logical units: When feasible, select entire functions, classes, or modules to provide Sypha complete context
  • Include imports: For language-specific assistance, include relevant imports so Sypha comprehends dependencies
  • Combine with @ mentions: For complex issues, utilize code commands along with file or problem mentions for additional context
  • Use keyboard shortcuts: Accelerate your workflow by assigning keyboard shortcuts to common code commands

Next time you're struggling with a piece of code, try utilizing Sypha's code commands instead of switching to a separate chat interface. You'll be amazed at how much more efficient your workflow becomes when AI assistance is integrated directly into your editor.

On this page