Vladyslav Krylasov's website

Go easy on hosted services when using AI agents

Published on

Contents

AI agents are now part of how a lot of us write code, and that isn’t going away. But every time an agent “just checks” a file on a forge, it sends a request to someone’s server. Multiply that by every agent, every session, and every retry, and the people who keep that infrastructure running pay for it in hosting bills and in hours spent on defenses.

What maintainers are saying

In Please stop externalizing your costs directly into my face, Drew DeVault writes that in some weeks, fighting LLM crawlers at SourceHut took 20 to 100% of the working time. The crawlers ignore robots.txt and hit expensive endpoints like git blame, every page of git log, and every commit in every repo. They cause dozens of brief outages per week.

In Protecting our FLOSS commons from LLMs, Codeberg describes crawlers reading every issue filter variant, the whole Git history, and every file at every revision, even unchanged ones. Those requests trigger expensive database queries, and the defenses admins build against them end up limiting legitimate users too. Their advice is short: “Just run git clone and enjoy.”

Both would rather you didn’t use LLMs at all. If you use them anyway, don’t add to the problem. An agent browsing a forge interactively hits the same expensive pages those crawlers do.

The idea

Fetch once, work locally. An agent reading a repository page by page through the web UI makes dozens of requests. One git clone does the same job.

Instead ofDo
Reading files via web UI or raw URLsOne shallow git clone
Cloning again in the next sessiongit fetch the existing clone
API calls for history and file listsgit log, git ls-tree, git grep
Scraping docs page by pageDownload the package, archive, or dump
Polling for statusCheck once, or wait for a notification
Pushing every attempt to hosted CITest locally, keep CI and releases lean

Tell your agent

Agents follow their instruction file, so put the rule there. Here’s the section from my global ~/.claude/CLAUDE.md:

## Go easy on hosted services

- To read code, history, or docs from a hosted repo (GitHub, GitLab,
  Codeberg, etc.), prefer one `git clone` over repeated API calls,
  raw-file fetches, or crawling the web UI page by page. It's one
  request instead of dozens, and it reduces load on the admins who
  run those services.
  - Clone into `~/.cache/repos/<host>/<owner>/<repo>`, not the
    scratchpad or `/tmp`, so the clone survives reboots and later
    sessions can reuse it. Writing there is allowed without asking.
  - E.g. `git clone --no-checkout --depth 1 <url> ~/.cache/repos/<host>/<owner>/<repo>`,
    then explore locally with `git grep <pattern> HEAD`,
    `git show HEAD:<path>`, `git ls-tree -r HEAD`. Drop `--depth 1`
    when you need history.
  - Before cloning, check whether that path already exists. If it
    does, `git fetch` it instead of cloning again.
- Same idea for other services: download a dump, archive, or package
  once instead of scraping, reuse what you've already fetched, and
  don't poll.

The same works for AGENTS.md or whatever file your tool reads.

Keep clones somewhere that lasts

Agents often put temporary files in a scratchpad under /tmp. On most Linux systems, /tmp is wiped on reboot or cleaned out after a few days. When that happens, the rule to reuse an existing clone stops working without any warning, and every restart means cloning everything again.

Point the agent at a directory that persists, like ~/.cache/repos/. A <host>/<owner>/<repo> layout keeps paths predictable, so a later session can find the clone and fetch it instead of downloading it again. If your instruction file restricts writes outside the project, add an explicit exception for this directory, or the agent will fall back to /tmp.

What’s in there is still third-party code, so treat it as untrusted. Read it, but don’t run or build it without checking first.

Exploring a clone locally

--no-checkout skips the working tree. You read files straight from git’s objects.

repo=~/.cache/repos/codeberg.org/owner/repo

git clone --no-checkout --depth 1 https://codeberg.org/owner/repo.git "$repo"

git -C "$repo" ls-tree -r --name-only HEAD   # list files
git -C "$repo" grep -n "pattern" HEAD        # search
git -C "$repo" show HEAD:path/to/file        # read a file

git -C "$repo" fetch --depth 1 origin        # update later
git -C "$repo" show FETCH_HEAD:path/to/file

Summary

  • AI agents aren’t going away, but their costs shouldn’t fall on the volunteers who run forges.
  • Clone once, explore locally, and fetch to update.
  • Keep clones in a persistent directory, not /tmp, so they survive reboots.
  • Write the rule into your agent’s instruction file so it’s the default.