DEV Community

Sherotree
Sherotree

Posted on Fully Autonomous

Stop the agent from adding a new HTTP client when the repo already has a fetch wrapper

The PR needs one JSON endpoint and adds axios, ky, or a new fetchClient.ts next to the feature. The repo already has a shared request helper that attaches the auth header, maps error payloads, and applies the existing timeout and credentials settings. Nearby hooks already use it. The new client retries differently, skips the shared error shape, and leaves a second dependency in package.json.

I've started treating a second HTTP client as a merge blocker, not as a harmless convenience. Getting a 200 back is the easy part. Auth, error mapping, and one place to change a base URL are why the wrapper exists.

Why the extra client shows up

A tutorial "call the API" example installs axios and writes axios.get. The model can do that without finding lib/api or fetchWithAuth. Your helper may be a thin api.get around fetch, which is easy to miss if the prompt only says "load the list from /api/items."

You also skip the existing interceptors, CSRF header, and the rule about not parsing errors twice.

A simple HTTP-client policy

  • New requests go through the existing fetch or API wrapper
  • Do not add axios, ky, or a second helper in a feature PR
  • Do not call raw fetch in a component when the wrapper is what the rest of the app uses
  • A new retry or base-URL rule is a wrapper change, with a test

If the endpoint is a third-party SDK with its own client, that is a documented exception, not a reason to wrap every internal route the same way.

What to put in the prompt

Use the existing API or fetch wrapper for this request.
Do not add axios, ky, or a new client file in this PR.
Keep the existing auth header and error mapping.
If you need a new timeout or base URL, extend the wrapper; do not invent a second one.
Enter fullscreen mode Exit fullscreen mode

Paste one existing wrapper usage. In review, search the diff for a new HTTP dependency, a raw fetch( in a component, and a helper that reimplements auth or error parsing.

Reject / send back

Reject

  • A new HTTP library added for one endpoint
  • A feature-level client that reimplements the wrapper
  • Raw fetch in UI code when the shared helper is the convention
  • A second error shape that the rest of the app will not handle

Accept

  • A request that uses the existing wrapper
  • A wrapper PR that adds a documented option and a test
  • A third-party SDK used only for that vendor's API, with a short comment

Top comments (1)

Collapse
 
dosaygo profile image
dosaygo •

Negative prompt rules like "do not add axios or a new client file" fail the moment the context window fills up; making the agent print the exact path and exported symbol of the existing wrapper on line one of its plan before touching a file is what actually kills duplicate clients.