Package scripts
Run existing JavaScript or Python checks without writing a Latch config.
Latch can discover named hooks in package.json and packaged uv projects.
If discovery finds the checks you need, you can skip latch.json. For any
other project command, configure it directly.
Latch looks in the harness or CLI working directory.
| Project file | After a supported edit | At turn end |
|---|---|---|
package.json | hook:afteredit | hook:turnend |
pyproject.toml with uv | hook-afteredit | hook-turnend |
Try the runnable examples or run latch explain turn_end
to see which script Latch resolved.
JavaScript and TypeScript
{
"scripts": {
"hook:afteredit": "prettier --check src",
"hook:turnend": "tsc --noEmit && vitest run --no-color"
}
}Install the project's dependencies first. This example uses Prettier,
TypeScript, and Vitest. Latch uses packageManager to select
npm, pnpm, Yarn, or Bun. Without that field, it uses the local lockfile or
defaults to npm. If lockfiles point to different managers, set packageManager
explicitly.
To reuse existing scripts in an npm project, set
"hook:afteredit": "npm run lint" for lint or "hook:turnend": "npm test" for tests.
Python with uv
[project.scripts]
hook-afteredit = "latch_python_example.checks:after_edit"
hook-turnend = "latch_python_example.checks:turn_end"Use a packaged Python project with a build system. Replace
latch_python_example.checks:after_edit and :turn_end with the Python
functions that run your project’s checks and return their exit status.
Install uv on the harness’s PATH. Latch invokes the entry points with
uv run hook-afteredit and uv run hook-turnend.
If you already run commands such as uv run ruff check . or
python -m unittest, you can configure those commands directly
without packaging Python entry points.
When both manifests define the same event, JavaScript runs before Python.
The scripts inherit any defaults in latch.json.
Try the examples
The example READMEs contain the complete steps for terminal and agent sessions. Browse the runnable projects
TypeScript example
See how Latch discovers Prettier, TypeScript, and Vitest through npm scripts in the TypeScript example.
Python example
See how uv console scripts supply the checks and latch.json supplies
shared settings in the Python example.