AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Use Codeium Command for In-Line Code Refactoring and Docstring Generation

365Finds Editorial
Indexed 11,430 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Codeium Command provides an in-editor, instruction-driven interface designed specifically for local code transformations. Unlike passive tab-autocomplete or conversational sidebar chat, Command operates directly inside your active code buffer. By pressing Ctrl+I (Windows/Linux) or Cmd+I (macOS), software engineers can issue natural-language directives to restructure messy logic, modernize legacy patterns, or generate standardized function docstrings without context switching.

This guide walks through the mechanics of Codeium Command, actionable refactoring workflows, docstring conventions across major languages, and best practices for evaluating inline diffs.


What Is Codeium Command?

Codeium organizes developer interactions into three distinct modalities:

  1. Flow (Autocomplete): Low-latency, passive code completion triggered keystroke by keystroke as you type.
  2. Discover (Chat): Sidebar conversation powered by repository indexing, best suited for exploring architecture, asking questions, or understanding unfamiliar codebases.
  3. Instruct (Command): Targeted, active instructions given directly at the cursor or over highlighted text.

Before Command, developers frequently resorted to "comment-driven prompting"—typing comments like // refactor this to async/await into the editor buffer and hoping autocomplete would guess the transformation, only to manually delete the comment afterward. Codeium Command replaces that awkward workaround with an interactive floating prompt that generates inline diffs directly in your editor.

Command is natively supported across Visual Studio Code, JetBrains IDEs (IntelliJ IDEA, PyCharm, WebStorm, GoLand), and the Windsurf Editor.


Performing In-Line Code Refactoring

Codeium Command shines when executing scoped, single-file code refactors where you know what changes need to happen and want the AI to handle the boilerplate, syntax shifts, and edge-case handling.

Basic Refactoring Workflow

  1. Highlight the target code: Select the function, loop, or logic block you want to restructure.
  2. Trigger Command: Press Ctrl+I (Cmd+I on macOS) or click the Refactor CodeLens floating above the function.
  3. Enter an explicit directive: Type what needs to change, focusing on design patterns, clarity, or error resilience.
  4. Inspect the inline diff: Codeium highlights additions in green and deletions in red directly in the buffer.
  5. Accept, reject, or iterate:
    • Press Alt+A (or Enter depending on keybindings) to accept the diff.
    • Press Alt+R (or Esc) to reject and restore original code.
    • Type a follow-up directive into the prompt bar if the result needs fine-tuning before accepting.

Key Refactoring Scenarios and Prompts

1. Modernizing Asynchronous and Legacy Logic

Converting older callback pyramids or chained .then() promises into clean async/await syntax with structured error handling.

Prompt:

"Refactor this Promise chain to use async/await with a try/catch block that logs errors to logger.error."

Before (JavaScript):

function fetchUserData(userId) {
  return getUser(userId)
    .then(user => {
      return getProfile(user.profileId)
        .then(profile => {
          return { user, profile };
        });
    })
    .catch(err => {
      console.error(err);
      throw err;
    });
}

After Codeium Command:

async function fetchUserData(userId) {
  try {
    const user = await getUser(userId);
    const profile = await getProfile(user.profileId);
    return { user, profile };
  } catch (error) {
    logger.error('Failed to fetch user data:', error);
    throw error;
  }
}

2. Simplifying Complex Conditionals and Guard Clauses

Deeply nested if/else ladders obscure business logic. Command can flatten control flow into early return guard clauses.

Prompt:

"Flatten this nested conditional using early return guard clauses and descriptive variable names."

3. Extracting Helper Functions and Improving Modularity

When a method handles too many responsibilities, highlight the auxiliary block and instruct Command to extract it.

Prompt:

"Extract the validation rules in this function into a separate pure helper function called validatePayload."

4. Type Safety and Input Hardening

Adding runtime validation or static typing to loosely typed inputs.

Prompt:

"Add TypeScript type annotations for parameters and return types, and validate that input arrays are non-empty."


Generating Function Docstrings

Maintaining documentation is essential for code maintainability, but writing parameter tables, return descriptions, and error specifications by hand is tedious. Codeium Command automates docstring creation by reading the function's arguments, internal control flow, and return values.

Two Ways to Trigger Docstring Generation

  1. Via CodeLens: Hover or look directly above any function or class declaration. Codeium displays a clickable Generate Docstring or Docstring CodeLens. Clicking it immediately analyzes the signature and injects standard documentation.
  2. Via Command Prompt (Ctrl+I / Cmd+I): Highlight the function definition and specify your preferred documentation convention.

Enforcing Specific Documentation Standards

Generic LLMs often produce bloated or non-standard docstrings. To get consistent results across your engineering team, mention the documentation standard directly in your prompt:

Because Codeium Command is trained on commit diffs and real-world instruction-following tasks, it avoids duplicating the function signature or prefix/suffix lines, placing the comments cleanly at the correct indentation level.


Effective Tips and Best Practices

To get the most out of Codeium Command while preserving repository quality, follow these engineering practices:


References