Replit provides AI-powered code suggestions through two features: Ghostwriter (now integrated into the editor) for inline autocomplete, and Replit Assistant for chat-based help. Code suggestions appear automatically as you type; press Tab to accept or Escape to dismiss. You can scope AI context with @file mentions, configure suggestion behavior in Settings, and use Agent for more complex code generation tasks.
Get the Most Out of Replit's AI Code Suggestions
This tutorial explains how Replit's AI code suggestion features work and how to configure them for your development style. You will learn how inline completions appear, how to accept or reject them, how to use the AI Assistant for contextual help, and how to adjust settings for the best experience. This guide is for anyone using Replit who wants to code faster with AI assistance.
Prerequisites
- A Replit account (any plan, though Core/Pro unlocks full AI features)
- A Replit App with some existing code
- No prior AI coding tool experience required
Step-by-step guide
Understand how inline code suggestions work
Understand how inline code suggestions work
As you type code in the Replit editor, AI-powered suggestions appear automatically as grayed-out text after your cursor. These suggestions predict what you are about to write based on your current file, the context of your project, and the language you are using. Suggestions can be a single line or multiple lines. They appear within 1-2 seconds of pausing your typing. You do not need to activate anything; suggestions are enabled by default on all plans.
Expected result: As you type, you see grayed-out code suggestions appearing inline after your cursor position.
Accept, dismiss, or partially accept suggestions
Accept, dismiss, or partially accept suggestions
When a suggestion appears, you have three options. Press Tab to accept the entire suggestion and insert it into your code. Press Escape to dismiss the suggestion and continue typing manually. On some setups, you can also press the right arrow key to accept one word at a time instead of the entire suggestion. If you keep typing and the suggestion no longer matches what you are writing, it automatically disappears and a new suggestion may appear based on your updated context.
Expected result: Pressing Tab inserts the suggested code. Pressing Escape dismisses it. Continuing to type triggers a new contextual suggestion.
Use Replit Assistant for chat-based code help
Use Replit Assistant for chat-based code help
Replit Assistant is a separate AI feature from inline suggestions. It is a chat interface where you can ask questions about your code, request explanations, or ask for code snippets. Open the Assistant from the AI panel or chat area in the workspace. Type your question in natural language. Use @file syntax to reference specific files for context. For example, '@src/App.jsx How do I add a loading spinner to this component?' gives the Assistant focused context to provide a relevant answer. Assistant consumes roughly 5 times fewer credits than Agent.
Expected result: Assistant responds with contextual code suggestions, explanations, or complete snippets based on your question and the referenced files.
Configure AI suggestion settings
Configure AI suggestion settings
You can adjust how AI code suggestions behave in your Replit workspace. Open Settings (click the gear icon or navigate through the account menu). Look for AI or Code Intelligence settings. You can toggle inline suggestions on or off, adjust the suggestion delay, and configure which file types receive AI assistance. If suggestions are distracting or you prefer a specific section to be written manually, you can temporarily disable them and re-enable when needed.
Expected result: Your AI suggestion behavior matches your preferences. You can toggle suggestions on/off and adjust their frequency.
Scope AI context with comments and structure
Scope AI context with comments and structure
The quality of AI suggestions improves dramatically when your code is well-structured and commented. Write descriptive function names, add JSDoc or docstring comments before functions, and use clear variable names. The AI reads your current file and surrounding context to generate suggestions. A well-commented file with clear patterns produces much better suggestions than uncommented spaghetti code. You can also write a comment describing what you want, and the AI will often generate the complete implementation.
1// Example: Writing a comment to guide AI suggestions23/**4 * Validates an email address format using regex5 * @param {string} email - The email address to validate6 * @returns {boolean} True if the email format is valid7 */8// Start typing the function and AI will suggest the implementation:9function validateEmail(email) {10 // AI typically suggests something like:11 // const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;12 // return regex.test(email);13}Expected result: After writing a comment or function signature, AI suggestions appear with relevant implementation code that matches your described intent.
Use Agent for complex multi-file code generation
Use Agent for complex multi-file code generation
For changes that span multiple files or require installing packages, use Replit Agent instead of relying on inline suggestions. Agent operates autonomously: it creates files, modifies existing code, installs dependencies, and tests its work. Open the Agent chat and describe what you want in natural language. Use Lite mode for small, focused changes (under $0.25/task) and Autonomous mode for larger features. Agent creates checkpoints at each step, so you can roll back if the result is not what you expected.
Expected result: Agent generates code across multiple files, installs dependencies, and tests the result. You can review and accept or roll back the changes.
Complete working example
1/**2 * Validation utility module3 * Well-structured code with clear comments produces better AI suggestions.4 * Write the function signature and docstring, then let AI complete the body.5 */67/**8 * Validates an email address format9 * @param {string} email - The email to validate10 * @returns {boolean} True if valid email format11 */12function validateEmail(email) {13 if (!email || typeof email !== 'string') return false;14 const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;15 return regex.test(email);16}1718/**19 * Validates a password meets minimum requirements20 * @param {string} password - The password to validate21 * @returns {{ valid: boolean, errors: string[] }}22 */23function validatePassword(password) {24 const errors = [];25 if (!password || password.length < 8) {26 errors.push('Password must be at least 8 characters');27 }28 if (!/[A-Z]/.test(password)) {29 errors.push('Password must contain at least one uppercase letter');30 }31 if (!/[0-9]/.test(password)) {32 errors.push('Password must contain at least one number');33 }34 return { valid: errors.length === 0, errors };35}3637/**38 * Sanitizes a string by removing HTML tags and trimming whitespace39 * @param {string} input - The string to sanitize40 * @returns {string} Sanitized string41 */42function sanitizeInput(input) {43 if (!input || typeof input !== 'string') return '';44 return input.replace(/<[^>]*>/g, '').trim();45}4647/**48 * Validates a URL format49 * @param {string} url - The URL to validate50 * @returns {boolean} True if valid URL51 */52function validateUrl(url) {53 try {54 new URL(url);55 return true;56 } catch {57 return false;58 }59}6061module.exports = {62 validateEmail,63 validatePassword,64 sanitizeInput,65 validateUrl66};Common mistakes
Why it's a problem: Accepting every suggestion without reading it, introducing subtle bugs
How to avoid: Always read the suggested code before pressing Tab. Check for incorrect variable references, off-by-one errors, and assumptions about data types.
Why it's a problem: Using Agent for simple tasks that could be handled by Assistant, wasting credits
How to avoid: Use Assistant for explanations, quick code snippets, and single-file changes. It costs roughly 5x fewer credits than Agent. Reserve Agent for multi-file changes.
Why it's a problem: Expecting AI suggestions in empty files with no context
How to avoid: Add at least a comment, import statement, or function signature to give the AI context. Suggestions are based on surrounding code; an empty file provides nothing to work with.
Best practices
- Write descriptive comments and function signatures before implementation to guide AI suggestions
- Use @file context when chatting with Assistant to get relevant, project-aware responses
- Press Tab to accept suggestions, Escape to dismiss, and keep typing to trigger new ones
- Use Assistant for quick questions (5x cheaper than Agent) and Agent for multi-file changes
- Start with Lite mode for Agent tasks to save credits on simple changes
- Use clear variable names and consistent coding patterns so AI suggestions match your style
- Disable suggestions temporarily in Settings when you need to think through complex logic manually
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I'm using Replit and want to get better AI code suggestions. How do I configure the settings, use @file context effectively, and structure my code so the AI gives me more accurate completions? I'm building a Node.js Express API.
Help me understand the best way to use your code suggestions. I'm working on @src/utils/validation.js and need to add input validation functions for email, password, and phone number. Show me how to write the function signatures and comments so you can suggest the implementations.
Frequently asked questions
Inline code suggestions are included on all plans, but free Starter accounts have limited daily AI usage. Core ($25/mo) and Pro ($100/mo) plans include full AI features with higher usage limits.
Ghostwriter (now integrated into the editor) provides inline code completions as you type. Agent is an autonomous AI that builds entire features, creates files, installs packages, and tests code. Ghostwriter assists your typing; Agent works independently.
AI suggestions rely on context from your current file and project structure. Add descriptive comments, use clear variable names, and include import statements at the top of files. The more context the AI has, the better its suggestions.
Replit has its own built-in AI and does not support installing GitHub Copilot or other AI extensions. If you prefer Copilot, consider using Cursor or VS Code instead. Replit's AI is tightly integrated with the platform's features.
Press Escape to dismiss any suggestion. If suggestions are consistently unhelpful, disable them in Settings. You can also add comments like '// Manual implementation:' to signal that you want to write the code yourself.
Replit's privacy policy states that code may be used to improve AI models unless you opt out. On Business and Enterprise plans, privacy mode can be enforced organization-wide. Check your plan's privacy settings for specifics.
Type @filename in the AI chat or Agent prompt to reference a specific file. For example, '@src/App.jsx add a loading state' tells the AI to look at that file for context. This produces more accurate and relevant responses than describing code verbally.
Yes. The RapidDev engineering team can help you structure your codebase, write effective AI prompts, and establish development patterns that maximize the value of Replit's AI suggestions and Agent features.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation