{"uid":"cap_8BxdTGC4-Vp5t0pTDAnyQ","slug":"code-refactoring-with-diff-and-rationale-bf15a998","name":"Code Refactoring with Diff and Rationale","description":"Refactor code while preserving behavior. Returns diff + rationale.","url":"https://pearl-valium-stickers-upc.trycloudflare.com/v1/coder/refactor?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"usage":{"type":"object"},"choices":{"type":"array"}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.03","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.03/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.03","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.03","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_yC0nKytBmrmbANGPEc337","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.03","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Refactors a code snippet while preserving its behavior, returning a unified diff and a written rationale explaining each change.","exampleAgentPrompt":"Can you refactor this Python function to reduce nesting and improve readability, then show me exactly what changed as a diff along with a brief explanation of why each change was made?","exampleUseCases":[{"title":"Legacy function cleanup","prompt":"I have this messy JavaScript function full of nested callbacks — can you refactor it to use async/await, show me the diff, and explain why the structure changed?"},{"title":"Duplicate code elimination","prompt":"This Java class has a lot of repeated logic — refactor it to eliminate duplication without changing what it does, and give me a diff plus rationale for each change."},{"title":"Readability improvement before code review","prompt":"I'm about to submit a pull request. Can you clean up this Python module for readability and maintainability, give me the unified diff, and explain your reasoning so I can include it in the PR description?"}],"resultDescription":"Returns a unified diff showing the exact lines added and removed, plus a written rationale explaining the motivation and reasoning behind each refactoring decision. Behavior of the code is preserved throughout.","failureModes":["Malformed or unparseable code input may produce an empty diff or error response","Highly context-dependent code (e.g. relying on external state) may have behavior-preservation guarantees violated","Very large code files may exceed model context limits and return partial results","The endpoint may be temporarily unavailable as it runs on a single ephemeral Cloudflare tunnel host","Payment failure (x402) will prevent execution and return a 402 response"],"whenToPreferThis":"Choose this endpoint when you need both a machine-readable diff AND a human-readable rationale for code changes — not just a reformatted version. It is particularly useful before code reviews, when onboarding to unfamiliar codebases, or when you need to justify refactoring decisions to a team. It runs on a local uncensored model, making it suitable for proprietary code that should not leave a controlled environment.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-31T18:39:20.904Z","isFirstParty":false,"canonicalSlug":"code-refactoring-with-diff-and-rationale-bf15a998"}