# Toolchain

> Run source files directly with Elide, then add an elide.pkl manifest to install dependencies, build, test, format and package a project.

Elide runs source files directly. Add an `elide.pkl` manifest for dependencies, builds, tests and artifacts.

## Start with a source file

The file extension picks the language:

```bash
elide app.js
elide app.ts
elide app.py
```

Explicit forms:

```bash
elide run app.ts
elide python app.py
```

## Common workflows

| Task | Command | Notes |
| --- | --- | --- |
| Run JavaScript or TypeScript | `elide run app.ts` | Types are stripped. |
| Run Python (experimental) | `elide python app.py` | Needs `elide setup python`; see [Python Toolchain](https://elide.help/docs/python-toolchain). |
| Compile Java | `elide javac -- -d out Hello.java` | |
| Compile Kotlin | `elide kotlinc -- -d out Hello.kt` | |
| Compile freestanding C | `elide cc -- -c answer.c -o answer.o` | [Embedded C compiler and linker via LLVM](https://elide.help/docs/toolchain/native/cc); native tools required. |
| Generate Java bindings for C | `elide jextract -- --output generated api.h` | [C header bindings](https://elide.help/docs/toolchain/native/jextract); native tools required. |
| Format Java and Kotlin | `elide format -- src` | `-n` after `--` checks only. |
| Install dependencies | `elide install` | Maven by default; `--ecosystems=npm` for npm. |
| Build a project | `elide build` | Needs `elide.pkl`. |
| Run tests | `elide test` | JVM tests need `elide.pkl`. |
| Rewrite Java (experimental) | `elide rewrite RECIPE --dry-run` | Preview an [OpenRewrite recipe](https://elide.help/docs/toolchain/jvm/rewrite). |
| Inspect dependency code (experimental) | `elide index build --layers=l1,l2,l3` | Build the [code index](https://elide.help/docs/toolchain/jvm/code-index) for type and reference queries. |

<img src="https://elide.help/assets/demos/project-build.gif" alt="Building and running a Kotlin project with Elide" width="1591" height="910" loading="lazy" decoding="async" class="rounded-lg border border-border my-6 w-full" />

## Direct tools

Elide's options go before `--`; the wrapped tool's go after:

```bash
elide javac -- -d out Hello.java
elide kotlinc -- -d out Hello.kt
elide jar -- --create --file app.jar -C out .
elide mvn -- package
```

Wrapped tools: `java`, `javac`, `javap`, `jdeps`, `javadoc`, `jar`, `javaformat`, `kotlinc`, `ktfmt`,
`native-image`, `mvn`, `jextract`, `cc`. `elide <tool> --help` shows Elide's options and how to show the tool's own help.

Native tools (`cc` and `jextract`) are included in Elide 1.6.2 on macOS arm64 and
dynamically linked Linux amd64/arm64. They are omitted from Windows, fully static builds and custom builds
using `--no-jvm-toolchain`. See [Embedded C compiler and linker via LLVM](https://elide.help/docs/toolchain/native/cc) for object/IR
output, in-memory JIT linking and platform boundaries. The
[Java compiler](https://elide.help/docs/toolchain/jvm/javac#c-header-bindings) can also generate C bindings during compilation.

To use these from Maven, Gradle or Bazel without an `elide.pkl`, see [Build tool integration](https://elide.help/docs/build-tools).

## Project-aware commands

```pkl
amends "elide:project.pkl"

name = "my-project"
```

```bash
elide install
elide build
elide test
elide run
```

All take `-p PATH` (project directory) and `-f NAME[=VALUE]` ([build flags](https://elide.help/docs/toolchain/build-flags)).
`elide help options` lists every global flag. Next: [Project setup](https://elide.help/docs/projects).

## OpenRewrite (experimental)

Preview and apply Java recipes in a project with `elide.pkl`:

```bash
elide rewrite --list
elide rewrite org.openrewrite.java.RemoveUnusedImports --dry-run
elide rewrite org.openrewrite.java.RemoveUnusedImports
```

See [OpenRewrite](https://elide.help/docs/toolchain/jvm/rewrite) for recipe modules, prefiltering, and experimental compatibility limits.

## Dependency code index (experimental)

Find which dependency defines a type and which compiled local sources use it:

```bash
elide index build --layers=l1,l2,l3
elide index status
elide index used-by java.util.List
```

See [Dependency code index](https://elide.help/docs/toolchain/jvm/code-index) for addresses, class resolution, member queries, and
reference queries over Maven dependencies and local Java and Kotlin classes.
