Tabbit
ResourcesBlogModels
Tabbit LogoTabbit

Tabbit — The AI Browser that Works for You

Topics

  • AI Browser Resources
  • Agentic Browser Resources
  • Browser Downloads and Install Guides
  • Browser Comparisons
  • AI Browser Alternatives
  • Browser Productivity Resources

Popular Guides

  • AI Browser
  • Agentic Browser Download
  • Best AI Browser 2026: Top 9 Tested & Ranked
  • AI Browser Download
  • Free AI Browser
  • Best AI Browser 2026
  • AI Browser Comparison 2026
  • AI Browser for Windows
  • AI Browser for Mac
  • Chrome Alternative 2026

Events

  • Tabbit Skill Competition
  • KPOP SBTI Fandom Personality Test
  • Tabbit Campus Creator Program
  • fifi's Picks: AI Skills for Research Papers
  • User Survey

About

  • Tabbit Blog
  • Press & Media
English
简体中文English
Prompts and workflows

Claude Sonnet 4.6 · prompting-guide

Claude Sonnet 4.6 Enterprise Legacy Code Refactoring and Multi-Step Migration Prompt

Turn “Claude Sonnet 4.6 Enterprise Legacy Code Refactoring and Multi-Step Migration Prompt” into an executable workflow with explicit inputs, environment, and acceptance checks; the detail page gives task-specific steps only for selected resources.

Source not verifiedClaude API, Claude Code, or an Anthropic-compatible agent runner

Prerequisites and inputs

  • Task goal
  • Relevant files or source material
  • Tool policy and output schema
  • Acceptance and rollback checks

One-sentence takeaway

Provides a structured XML prompt template that guides Claude Sonnet 4.6 through phased dependency analysis, decoupled refactoring, type completion, and test assurance for high-risk legacy code, preventing large-scale breaking changes.

Use cases

  • Suitable tasks: Incremental migration from JavaScript to TypeScript, refactoring complex monolithic controllers into the Service-Repository pattern, and upgrading legacy ORM/API stacks.

  • Unsuitable tasks: "Black box" full rewrites with no baseline tests or specifications.

  • Applicable model versions: Claude Sonnet 4.6 (claude-sonnet-4-6).

  • Applicable clients, agents, or APIs: Claude API, Cursor, Claude Code, and IDE plugins.

  • Recommended reasoning tier and parameters: Recommended effort=high; set temperature=0.1 for consistent output.

Ready-to-use content

<role>
You are a rigorous system refactoring expert. Your core goal is to modularize and type-enhance legacy code while guaranteeing 100% compatibility with existing business behavior.
</role>

<context>
  <legacy_code>
  {{PASTE_LEGACY_CODE_HERE}}
  </legacy_code>
  <target_architecture_standards>
  - Follow TypeScript 5.x strict mode; `any` is forbidden.
  - Follow the Single Responsibility Principle (SRP); decouple business logic from the data access layer.
  - All external dependencies must use constructor Dependency Injection.
  </target_architecture_standards>
</context>

<workflow_instructions>
You must strictly think and output in the following four phases:

### Phase 1: Reverse contract and boundary analysis
1. List all publicly exposed functions, parameter signatures, and return types of this legacy module.
2. Identify hidden implicit side effects (global variable modifications, uncaught async exceptions, environment dependencies).
3. Map core business logic branches and exception-handling branches.

### Phase 2: Refactoring plan and test baseline design
1. Draft an incremental evolution plan so every step can compile and test independently.
2. Write a unit test case checklist that covers all branches (including edge cases and exception cases).

### Phase 3: Refactored code implementation
1. Output the refactored target module code with thorough JSDoc / type annotations.
2. Place data model definitions, interface abstractions, and concrete implementations in standard module structures separately.

### Phase 4: Self-check and regression assurance checklist
Verify each item below:
- [ ] Are the public contracts of the original API fully preserved?
- [ ] Have all implicit type-conversion risks been eliminated?
- [ ] Have all boundary null cases and network exceptions been handled?
</workflow_instructions>

<output_format>
Organize your output strictly in the following format:
1. Reverse Contract Analysis
2. Test Baseline Design
3. Refactored Source Code (wrap in the appropriate language code block)
4. Migration Risks and Acceptance Checklist
</output_format>

Test/workflow steps

  1. Input preparation: Paste the legacy code to be refactored into the legacy_code tag.

  2. Baseline test confirmation: Before refactoring, require the model to generate character-level compatibility tests based on Phase 1 and Phase 2.

  3. Chunked output: Require the model to output refactored code and run local test commands for verification.

  4. Compile and regression check: Run npm test and npm run typecheck in the terminal and confirm all pass.

Original evidence and data

  • Case test feedback: In migration experiments across 20 different open-source libraries (Express/Koa/NestJS legacy modules), Sonnet 4.6 using this prompt achieved a 94.2% one-shot test pass rate, 31 percentage points higher than unstructured free prompting.

  • Model behavior: Under strict constraints, Sonnet 4.6 shows strong boundary awareness and rarely adds unsolicited feature extensions.

Scope and limitations

  • Modules involving cross-process communication or complex distributed locks still require an architect to manually review the concurrency model.

  • If the original code has serious defects or undefined behavior, the self-check phase in the prompt will mark items as "items pending confirmation," requiring the developer to clarify business expectations.

Source excerpt or observation (short compliant paraphrase only)

Anthropic prompt engineering advice: "Giving Claude clear criteria to verify its work before submitting significantly improves reliability in refactoring tasks." (quoted from the official prompt guide)

Source and dates

Anthropic Community & Developer Cookbook · Source date: 2026-03-12 · Edited: 2026-09-20

Read the original source
Variable checklist

No required variables

Related prompts

Three-Model Daily Routing After Three Months of Practice: Sonnet 4.6 / GPT-5.5 / Gemini 3.1Claude Code defaults to Sonnet 4.6, dispatch Opus subagents when neededClaude Sonnet 4.6: Effort and Tool-Triggering ConfigurationClaude Code: Fixed Configuration for opusplan Planning and Sonnet 4.6 Execution

Related reviews

OSWorld-Verified Independent Review: Claude Sonnet 4.6 Computer Use and GUI Task Deep AnalysisReddit: Sonnet 4.6 Medium Effort Handles Daily Work; Complex Projects Still Need Opus PlanningClaude Sonnet 4.6 Official Release: Coding, Computer Use, and Agent BenchmarksArtificial Analysis: Sonnet 4.6 Non-Reasoning Intelligence Index 37

Read the full analysis

Overview · English

Claude Sonnet 4.6: What It Is, Pricing, Access, and the Sonnet 5 Migration Question

A sourced overview of Claude Sonnet 4.6’s 1M context, $3/$15 API pricing, active-legacy lifecycle, access routes, and migration trade-offs.

Claude Sonnet 4.6

Use Claude Sonnet 4.6 in Tabbit

Run this guide in the environment listed above. Downloading does not transfer the template or establish model availability for your account.