---
title: Use cases
description: "Five things garage does that account-bound, clone-first git hosting can't."
---

garage is git built for programs, not just people — anonymous, ephemeral,
typed, and scoped. Each use case below leads with a scenario, then shows the
smallest snippet that proves it.

## Throwaway repos for agents

An agent that needs real git semantics for a 20-minute task — not a permanent
home for the output. No signup, no cleanup, no orphaned repos: set a TTL and
it's gone.

```ts
import { garage } from '@thegarage/sdk'

// No auth, no account. Repo evaporates in 6h.
const git = await garage.ephemeral({ ttl: '6h' })

await git.add('plan.md', '# Refactor plan\n...')
await git.commit('scratch: working state')

console.log(await git.log())
```

```sh
garage anon create --ttl 6h        # same thing from the CLI
```

The default TTL is 24 hours and the maximum is 72 hours. See
[Anonymous repos](/docs/anon-push).

## Commit from memory — no clone, no filesystem

A serverless function, Worker, or sandboxed agent runtime with no working
tree. It produces files in memory and commits them atomically — no
`git clone`, no temp dir, no `git` binary.

```ts
const git = await garage('codegen-out', {
  token: process.env.GARAGE_API_KEY,
})

await git.add('src/client.ts', clientSrc)
await git.add('src/types.ts', typesSrc)
await git.remove('src/old-client.ts')

const commit = await git.commit('feat: regenerate client')
console.log(commit.url)
```

Every `add`/`remove` is staged in memory; `commit` writes them as a single
atomic commit. See the [Git SDK](/docs/sdk).

## Hand a repo to another agent

A supervisor agent that spins up work and grants a sub-agent access to exactly
one repo, for exactly as long as it needs. Tokens are scoped to a single repo
and op, with policy TTL caps — an `agent` token lives 30 minutes, then dies.

```sh
# Mint a write token scoped to one repo, one session
garage tokens mint codegen-out --scope write --op agent
```

```ts
const { token } = await client.tokens.mint({
  name: 'codegen-out',
  scope: 'write',
  op: 'agent',
})

const git = await garage('codegen-out', { token }) // sub-agent uses it
```

For a full handoff bundle — clone URL, config snippet, and a paste-ready
prompt — use `garage share my-api --role write --expires 7d --json`. See
[For agents](/docs/agents).

## Share a repo as a leak-proof link

Anyone pasting repo access into a chat, ticket, or another tool. The
credential should never be the thing you paste. Invite links carry **no
secret** — the token is minted fresh on reveal, capped by `maxReveals`, and
revocable independently of the repo.

```sh
garage share my-api --role read --link
# → https://thegarage.sh/invites/<id>   (safe to paste in Slack)
```

A receiving agent can redeem it directly as markdown:

```sh
curl 'https://thegarage.sh/invites/<id>.md?reveal=1'
```

Anonymous repos work the same way with `garage anon share <name>` — zero auth
on either side, and every share dies with the repo.

## Inspect a repo without cloning it

A code-review agent, dashboard, or CI step that needs to _read_ a repo, not
check it out. History and diff computation come back as structured data.

```sh
garage git diff my-repo main feature/x --json     # structured diff
garage git compare my-repo main feature/x         # ahead/behind + mergeability
```

```ts
const { files, stats } = await client.git.diff({
  name: 'my-repo',
  base: 'main',
  head: 'feature/x',
  includePatch: true,
})
// stats → { additions, deletions, changedFiles }
```

For a single file, skip RPC entirely and pull raw bytes (up to 10 MiB):

```sh
curl -H "Authorization: Bearer grg_..." \
  https://api.thegarage.sh/my-repo/raw/main/README.md
```

See the [CLI reference](/docs/cli).

  - [Getting started](/docs/getting-started): Install the CLI, sign in, and create your first repo.
  - [For agents](/docs/agents): Wire garage into your coding agent with the canonical SKILL.md.
  - [Git SDK](/docs/sdk): Commit from any JavaScript runtime — no clone required.
  - [Anonymous repos](/docs/anon-push): No-account ephemeral repos that expire on a TTL you set.
