# hushrun and Turborepo

Turborepo runs and caches tasks across the packages of a JavaScript or TypeScript monorepo, and its remote cache shares results between machines. hushrun wraps any command, in any repository, and skips it when the same files already passed. Turborepo is more precise in a monorepo. hushrun asks less of a repository, and also promotes artifacts.

| | Turborepo | hushrun |
|---|---|---|
| Setup | `turbo.json` and `package.json` scripts, in one package or a monorepo | `npx hushrun init` wraps your scripts |
| Key | Task definition, lockfile, global dependencies, declared environment variables, flags, arguments, package configuration and tracked files | The repository's files or a scope's, the check's name, the exact command and the directory |
| A one-package change | Runs affected packages | Runs every check, unless you set scopes |
| On a hit | Replays logs and restores outputs | Skips the command and restores nothing |
| Remote storage | Vercel, or a server implementing its API | hushrun's hosted service, or a server implementing its protocol |
| Promotion to production | No | Yes |

## How Turborepo caches

[Turborepo hashes each task](https://turborepo.dev/docs/crafting-your-repository/caching) from its definition, the lockfile, `globalDependencies`, `globalEnv`, flags, arguments, package configuration and tracked files. [The remote cache](https://turborepo.dev/docs/core-concepts/remote-caching) runs on Vercel, where it's free on all plans, or on any server that implements its API.

`turbo run --affected` runs only what changed against the base branch. [It needs enough git history](https://turborepo.dev/docs/reference/run): with too shallow a clone, everything counts as changed.

Test tasks cache per package. [Vitest Projects](https://turborepo.dev/docs/guides/tools/vitest), which run a whole monorepo's tests from the root, don't fit that model.

## How hushrun differs

- **No `package.json` needed.** `hushrun run` wraps any command, so it works in a repository that isn't JavaScript at all.
- **It compares the files.** So the key doesn't depend on declaring every input of each task, and you narrow it with [scopes](https://hushrun.com/docs/run.md#monorepos) when you want to.
- **It restores nothing.** A skip means the command didn't run, which suits checks but not a build whose output the next step needs. Keep Turborepo for builds.
- **Results say who ran them,** and reach coding agents' sandboxes through an [agent token](https://hushrun.com/docs/agents.md#sandboxes).
- **It goes on to deploy.** [Promotion](https://hushrun.com/docs/promotion.md) deploys the artifact staging validated, by digest.

## Using both

Wrap the Turborepo command, so that code that already passed runs nothing at all:

```json title="package.json"
"scripts": {
  "test": "hushrun run -- turbo run test"
}
```

## Which to choose

- **Choose Turborepo** for a JavaScript monorepo where you want tasks ordered and cached, builds included.
- **Choose hushrun** when you don't want to add a task runner, when your repository isn't JavaScript, or when you need to know who ran each result.
- **Use both** when you want Turborepo's precision and hushrun's promotion.

## Related

- [Cache test results across machines](https://hushrun.com/docs/guides/cache-test-results.md)
- [hushrun and Nx Cloud](https://hushrun.com/docs/compare/nx-cloud.md)
