Intermediate

Chat-Driven Development

The chat panel turns Gemini Code Assist from a completion engine into a collaborator. Learning to use @workspace syntax, slash commands, and context anchoring gets you precise answers instead of generic responses.

✍️ AI School Editorial Team · Lilly Tech Systems 📅 Published Aug 27, 2026 · Reviewed Aug 27, 2026

The Chat Panel Is Not a Chatbot

General-purpose chat tools like a web-based AI assistant know nothing about your codebase. They answer based on their training data and what you paste in. Gemini Code Assist's chat panel knows your open files, your project structure (with @workspace), and the context of your current selection. That context changes what is possible: instead of "here is an example of how to implement pagination," you get "here is how to add pagination to your UserRepository class using the Spring Data pattern you already use in ProductRepository."

Getting that level of specificity requires knowing how to give the model the right context. That is what this lesson covers.

Context Anchors: @file and @workspace

By default, the chat panel includes the currently active file as context. You can expand or narrow that context with @ syntax:

  • @workspace - Instructs the model to index and search your entire project before answering. Use this for questions that span multiple files: "where is the authentication middleware applied?" or "find all callers of this deprecated function."
  • @file:path/to/file.py - Pins a specific file as context without indexing the full workspace. Useful when you know exactly which file is relevant.
  • #selection - Pins the currently highlighted code as the subject of the request. The model focuses its response on that selection specifically.
Example: Context-specific chat prompts
# Too vague - gives a generic answer about caching in general
"How should I add caching?"

# Better - specific to your codebase
"@workspace How is caching currently implemented in this project?
What layer handles it?"

# Best for a specific change - pins the relevant file
"@file:src/services/user_service.py
Add Redis caching to the get_user_by_id method with a 5-minute TTL.
Use the existing cache client from config.py."

Slash Commands

Slash commands are pre-built workflows that trigger specific behaviors without requiring you to phrase the request yourself. Type / in the chat input to see available commands:

CommandWhat it doesBest used when
/explainExplains the selected code or current fileReading unfamiliar code or onboarding to a new codebase
/fixSuggests a fix for the selected code or current errorYou have an error message and want a starting point
/generateGenerates code from a natural-language descriptionCreating new functions, classes, or modules
/testsGenerates unit tests for the selected codeAdding test coverage to existing functions
/docGenerates documentation comments for selected codeDocumenting public APIs or complex functions
/optimizeSuggests performance or readability improvementsCode review of a function you suspect is slow or complex
Select before you slash. Slash commands work on the currently selected code if you have a selection, or on the entire current file if nothing is selected. Always highlight the specific function or class you want to work on before running /explain, /fix, or /tests. You get a more focused response.

Inline Actions: The Right-Click Workflow

For quick, targeted operations, right-clicking a code selection and choosing "Gemini Code Assist" gives you inline action options without switching to the chat panel. These are convenience wrappers around the same slash commands, but they insert the result directly into your file as a diff you can accept or reject - no copy-pasting from the chat window.

Common inline actions:

  • Explain this code - Opens an explanation in the chat panel
  • Generate unit tests - Creates a test file alongside the current file
  • Fix this issue - Available in the Problems panel when a linter or compiler error is highlighted
  • Add comments - Adds inline comments explaining the logic

Prompting Discipline for Useful Responses

The chat panel responds to the same principles as any other AI chat tool. Bad prompts get bad answers, even with good context anchors. A few rules that consistently produce better results:

📚
The CRAT framework for coding chat prompts:
  • C - Context. Tell it where in your system this code lives. "This is the payment processing service" or "this runs in a Lambda with 128MB RAM."
  • R - Requirements. State what you actually need, not just "make it better." Specific goals produce specific code.
  • A - Avoid. Tell it what not to do. "Do not change the function signature" or "do not add new dependencies."
  • T - Test case. If you have a failing test or a specific input/output pair, include it. Concrete examples anchor the response.
Vague prompt vs. CRAT prompt
# Vague - gets a generic refactor suggestion
"Refactor this function to be better"

# CRAT - gets a targeted, implementable change
"Context: This is the order validation service, called on every checkout.
Requirement: Reduce cyclomatic complexity below 10 without changing behavior.
Avoid: Changing the function signature or adding new imports.
Test: validate_order({'items': [], 'customer_id': None}) must still raise ValueError."

When Chat Is Better Than Completion

Completions are fast but context-limited. Chat is slower but can handle larger, more complex requests. Use chat when:

  • You need to explain a change before making it - "How should I approach migrating this from REST to GraphQL?"
  • You want to understand existing code before modifying it - "Explain what this reducer does step by step"
  • The change spans multiple files - "@workspace Update all callers of getUserById to pass the new tenant_id parameter"
  • You have a failed test or error message and need a diagnosis - paste the error and ask for root cause analysis

Use completions when you know what you are writing and just want the boilerplate filled in faster.

Ready to Go Deeper?

Live instructor-led courses from our partners. Affiliate disclosure.