AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Autonomous Coding with Code GPT Agent Mode in VS Code: Planning, File Creation, and Terminal Execution

Daniel Kräher · 365Finds Editorial
Indexed 88,650 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

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 ModeCapabilities & Tool AccessWorkspace ImpactIdeal Use Case
Chat ModeNo tools enabled; pure text Q&ARead-only; completely detached from local filesSyntax questions; algorithmic explanations; conceptual learning
Search ModeRead-only tools (Code Search, Read File, View Folder Structure)Read-only; inspects codebase without writingArchitecture audits; tracing dependency flows; codebase onboarding
Agent ModeFull internal toolset (Create File/Folder, Edit File, Delete File, Run Terminal Command)Full read, write, and execute permissionsMulti-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

  1. Open the Code GPT sidebar in VS Code.
  2. Click the profile selector dropdown located at the top of the chat panel.
  3. Switch from Chat Mode or Search Mode to Agent Mode (marked with the robot icon 🤖).
  4. 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.

Configuring Tool Modes: Enabled vs. Auto-Approve

Navigate to Code GPT Settings > Tools to configure how tools execute:


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:

  1. Define shared TypeScript interfaces in a new types file.
  2. Create dedicated service abstractions.
  3. Update consumers and route handlers to ingest new dependencies.
  4. Execute build and linter commands.
  5. 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:

  1. Discovery: Calls Read File on src/controllers/orderController.js and package.json.
  2. Scaffolding: Calls Create File/Folder for src/services/stripeService.ts and populates it with typed business logic.
  3. Refactoring: Calls Edit File on src/controllers/orderController.js, replacing inlined Stripe SDK calls with the imported service.
  4. Test Harness: Calls Create File/Folder for tests/services/stripeService.test.ts and writes mock fixtures.
  5. Terminal Command: Calls Run Terminal Command with npm test -- tests/services/stripeService.test.ts.

Step 3: Handling Self-Correction

If Vitest fails due to an outdated mock signature:


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 VectorFailure ModeRecommended Mitigation
Destructive Terminal ExecutionAgent 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 OverwriteMulti-file edits introducing subtle architectural driftAlways branch off git checkout -b refactor/agent-task before launching Agent Mode; diff review before merging.
Infinite Error LoopsAgent repeatedly alters code without resolving circular compiler errorsRely on Code GPT's 20 auto-approval cap; break down overly broad refactoring requests into smaller subtasks.
Token ExhaustionLong terminal stack traces flooding the model context windowUse targeted test filters (e.g., running single test files instead of full test suites).

The 365Finds Institutional Evaluation

  1. 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.
  2. Prefer Tiered Approvals: We do not recommend blanket "Auto-Approve" on production-bound repositories. The optimal operational configuration is setting Create File/Folder and Edit File to Auto-Approve, while retaining manual confirmation on Run Terminal Command and Delete File. This preserves autonomous flow while preventing accidental command execution or data loss.
  3. 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.

References