Traditional AI coding assistants operate like conversational code mirrors: they output static code blocks into a side panel, leaving developers to manually create target files, copy-paste snippets across multiple directories, and debug terminal commands by hand. For cross-module refactoring, new component scaffolding, and test harness setup, this copy-paste cycle destroys developer flow and introduces copy-paste regressions.
Code GPT transforms Visual Studio Code from a passive chat interface into an autonomous execution environment via its Agent Mode. By coupling language model reasoning with internal operating tools—specifically Read File, Code Search, Create File/Folder, Edit File, Run Terminal Command, and Update ToDo List—Code GPT autonomously plans complex architectural changes, generates and edits multi-file trees, and runs terminal verification commands within a closed self-healing loop.
At 365Finds, our research judgment is unambiguous: passive AI chat interfaces are obsolete for multi-file software engineering. An autonomous agent loop is the minimum baseline for modern refactoring. However, autonomy without guardrails is a liability. Teams should adopt Code GPT Agent Mode on isolated Git worktrees, pair it with frontier reasoning models, and enforce bounded auto-approvals for shell operations.
1. Understanding Code GPT Profile Modes: Why Agent Mode Matters
Code GPT structures its IDE interactions into three distinct operational profiles. Selecting the right mode dictates what tools the model can invoke:
| Profile Mode | Capabilities & Tool Access | Workspace Impact | Ideal Use Case |
|---|---|---|---|
| Chat Mode | No tools enabled; pure text Q&A | Read-only; completely detached from local files | Syntax questions; algorithmic explanations; conceptual learning |
| Search Mode | Read-only tools (Code Search, Read File, View Folder Structure) | Read-only; inspects codebase without writing | Architecture audits; tracing dependency flows; codebase onboarding |
| Agent Mode | Full internal toolset (Create File/Folder, Edit File, Delete File, Run Terminal Command) | Full read, write, and execute permissions | Multi-step refactoring; module scaffolding; automated test suites |
In Chat Mode, the assistant lacks workspace awareness. In Search Mode, it can read your project but cannot touch your file system. Agent Mode activates the full autonomous tool pipeline, granting Code GPT the ability to create folders, patch existing source code, inspect diffs, and invoke terminal processes.
How to Switch to Agent Mode in VS Code
- Open the Code GPT sidebar in VS Code.
- Click the profile selector dropdown located at the top of the chat panel.
- Switch from Chat Mode or Search Mode to Agent Mode (marked with the robot icon 🤖).
- Verify that the agent prompt displays active tool access icons.
2. Prerequisites: Tool Permissions and Model Configuration
Agent Mode depends on two architectural pillars: function-calling capable models and tool permission boundaries.
Selecting the Right Model Backend
Agentic workflows require advanced reasoning and reliable structured function calling. Selecting a weak or instruction-following-limited model will result in broken tool loops, malformed parameters, and syntax errors.
- Recommended Models (365Finds Pick): Anthropic Claude 3.5 Sonnet / Claude 3.7 Sonnet or OpenAI GPT-4o. These models consistently parse complex file dependencies and adhere strictly to JSON tool schemas.
- Alternative Options: DeepSeek-V3, Google Gemini 1.5 Pro, or OpenAI o-series reasoning models via Bring Your Own Key (BYOK) or Code GPT Plus managed credits.
- Important Constraint: In the Code GPT settings, ensure your chosen provider and model are listed under Providers and Models with Tools. If you select a model lacking native tool-calling capabilities, Code GPT disables autonomous agent actions automatically.
Configuring Tool Modes: Enabled vs. Auto-Approve
Navigate to Code GPT Settings > Tools to configure how tools execute:
- Enabled Mode (Manual Approval): The agent pauses before every file modification or terminal execution, presenting a visual diff or prompt requiring you to click "Approve" or "Reject". This provides complete control and is essential when learning the tool.
- Auto-Approve Mode (Autonomous Execution): The agent automatically runs file modifications and terminal commands based on context, without pausing for user intervention.
- The 20-Action Safety Ceiling: To prevent runaway loops and infinite execution cycles, Code GPT imposes a default safety limit of 20 consecutive auto-approved operations for potentially destructive actions (file creation, deletion, editing, and terminal commands). Once reached, Code GPT pauses and requires manual human confirmation to continue.
3. The Autonomous Execution Loop: How Agent Mode Operates
When an engineer issues a multi-step objective—such as refactoring an Express.js API client into a typed modular service—Code GPT initiates a systematic five-stage loop:
[ User Prompt ]
│
▼
[ 1. Workspace Discovery ] ───▶ (Code Search, Read File, View Folder Structure)
│
▼
[ 2. Autonomous Planning ] ───▶ (Update ToDo List & Task Sequencing)
│
▼
[ 3. File Scaffolding & Diffs ] ──▶ (Create File/Folder, Edit File)
│
▼
[ 4. Terminal Command Execution ] ─▶ (Run Terminal Command: Build / Test)
│
├───▶ [ Build/Test Fails ] ──▶ (Analyze Stderr & Return to Step 3)
│
▼
[ 5. Task Completion & Clean Diff Review ]
Stage 1: Workspace Discovery and Context Gathering
Rather than guessing imports, the agent calls View Folder Structure to understand project hierarchy and Code Search to identify all files referencing deprecated interfaces, database schemas, or legacy endpoints. It then calls Read File on targeted modules to map out contracts and import paths.
Stage 2: Autonomous Planning with ToDo Lists
For non-trivial refactoring, Code GPT invokes its Update ToDo List internal tool. It articulates explicit milestones:
- Define shared TypeScript interfaces in a new types file.
- Create dedicated service abstractions.
- Update consumers and route handlers to ingest new dependencies.
- Execute build and linter commands.
- Generate and execute end-to-end integration tests.
Visible progress tracking prevents the agent from losing task context across long inference chains.
Stage 3: File Creation and Surgical Editing
When scaffolding new logic, Code GPT calls Create File/Folder to instantiate clean paths (e.g., src/services/paymentService.ts). When updating existing callers, it calls Edit File to apply precise targeted replacements rather than overwriting entire files. VS Code displays visual diff decorations, allowing developers to observe changes in real time.
Stage 4: Integrated Terminal Command Execution
Once files are saved, the agent invokes Run Terminal Command. It triggers your project's native toolchain:
npm run build
# or
npx tsc --noEmit
# or
npm test -- tests/services/payment.test.ts
Stage 5: Self-Healing and Error Correction
If a terminal command exits with a non-zero code or emits TypeScript compiler errors (TS2304: Cannot find name...), Code GPT captures stdout and stderr directly from the terminal buffer. It diagnoses the root cause, calls Edit File to rectify the missing import or mismatched parameter, and re-executes the terminal test command autonomously until all checks pass.
4. Practical Implementation: Refactoring and Testing a Payment Service
To see Code GPT Agent Mode in action, consider a common full-stack refactoring scenario: splitting a legacy monolithic controller (src/controllers/orderController.js) into a decoupled service pattern with TypeScript types, automated Vitest tests, and terminal verification.
Step 1: Formulate the Agentic Prompt
In the Code GPT Agent Mode chat panel, supply an explicit, bounded prompt:
Refactor src/controllers/orderController.js by extracting all Stripe payment handling into a new service module:
1. Explore existing payment logic and shared configuration.
2. Create src/services/stripeService.ts with strict TypeScript interfaces for charge requests and responses.
3. Update src/controllers/orderController.js to consume the new stripeService.
4. Create tests/services/stripeService.test.ts covering success, card decline, and network timeout scenarios.
5. Run the test suite in the terminal using "npm test -- tests/services/stripeService.test.ts". If any tests fail, inspect the terminal output and self-heal the implementation until all tests pass.
Step 2: Observe Autonomous Step Execution
Code GPT executes the workflow across sequential tool calls:
- Discovery: Calls
Read Fileonsrc/controllers/orderController.jsandpackage.json. - Scaffolding: Calls
Create File/Folderforsrc/services/stripeService.tsand populates it with typed business logic. - Refactoring: Calls
Edit Fileonsrc/controllers/orderController.js, replacing inlined Stripe SDK calls with the imported service. - Test Harness: Calls
Create File/Folderfortests/services/stripeService.test.tsand writes mock fixtures. - Terminal Command: Calls
Run Terminal Commandwithnpm test -- tests/services/stripeService.test.ts.
Step 3: Handling Self-Correction
If Vitest fails due to an outdated mock signature:
- Code GPT reads:
AssertionError: expected mockPaymentIntent to have been called with.... - The agent invokes
Edit Fileontests/services/stripeService.test.tsto adjust the mock assertion parameters. - It invokes
Run Terminal Commandagain:Tests: 3 passed, 3 total. - Code GPT marks the task complete on its ToDo list and presents a concise summary of all altered files.
5. Security Guardrails, Trade-Offs, and 365Finds Judgment
While Code GPT Agent Mode delivers immense productivity gains, executing arbitrary terminal commands and mutating files carries operational risks that require clear organizational rules.
Operational Guardrails
| Risk Vector | Failure Mode | Recommended Mitigation |
|---|---|---|
| Destructive Terminal Execution | Agent attempts rm -rf, schema drops, or uncommitted git checkout . | Restrict destructive shell commands; keep terminal execution on Enabled (manual approval) for critical repos. |
| Silent Regression Overwrite | Multi-file edits introducing subtle architectural drift | Always branch off git checkout -b refactor/agent-task before launching Agent Mode; diff review before merging. |
| Infinite Error Loops | Agent repeatedly alters code without resolving circular compiler errors | Rely on Code GPT's 20 auto-approval cap; break down overly broad refactoring requests into smaller subtasks. |
| Token Exhaustion | Long terminal stack traces flooding the model context window | Use targeted test filters (e.g., running single test files instead of full test suites). |
The 365Finds Institutional Evaluation
- Abandon Chat-and-Copy Coding: Generating static code snippets in an editor side panel is an outdated workflow. Autonomous file scaffolding and terminal execution should be the standard setup for any developer undertaking refactoring or boilerplate generation.
- Prefer Tiered Approvals: We do not recommend blanket "Auto-Approve" on production-bound repositories. The optimal operational configuration is setting
Create File/FolderandEdit FiletoAuto-Approve, while retaining manual confirmation onRun Terminal CommandandDelete File. This preserves autonomous flow while preventing accidental command execution or data loss. - Model Selection Is Non-Negotiable: Do not attempt complex Agent Mode workflows using lightweight or older open-weights models lacking robust multi-step function calling. At current frontier performance, Claude 3.5/3.7 Sonnet and GPT-4o provide the lowest hallucination rates and the highest self-healing accuracy in VS Code.