mainline-layerfs
Use Mainline's Git-native repository memory while working in a LayerFS project.
Use when building, editing, testing or inspecting a project through LayerFS with the JavaScript SDK (`@layerfs/agent`) from the command line. Activates on LayerFS projects, Branches, Commits, Workspaces or Sandboxes; `LayerFS.open`, `LayerFS.init`, `layerfs.project.*`,
$ npx -y skills add mainline-org/mainline --skill layerfs-js-sdk --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/layerfs-js-sdkContext preview
The summary Claude sees to decide when to auto-load this skill.
Use when building, editing, testing or inspecting a project through LayerFS with the JavaScript SDK (`@layerfs/agent`) from the command line. Activates on LayerFS projects, Branches, Commits, Workspaces or Sandboxes; `LayerFS.open`, `LayerFS.init`, `layerfs.project.*`,
name: layerfs-js-sdk description: Use when building, editing, testing or inspecting a project through LayerFS with the JavaScript SDK (`@layerfs/agent`) from the command line. Activates on LayerFS projects, Branches, Commits, Workspaces or Sandboxes; `LayerFS.open`, `LayerFS.init`, `layerfs.project.*`, `layerfs.fs.*`, `layerfs.branch.*`, `layerfs.sandbox.*` or `layerfs.workspace.*` calls; running npm install, build or tests inside a mounted Workspace; or resolving LayerFS Conflict, Dirty or Busy refusals.
> **Status:** Current general guide for the current SDK source. Base example > outputs were captured live in issue #334 Phase A at `b30e4fb8f`; the > Workspace API and idle close are #373's (section 8 of > [its design](https://github.com/Ephemeral-AI-Lab/layerfs/blob/9f97a7ec95b662e9cb288704afa165feff132cfa/core/docs/issues/373/README.md)). The `@layerfs/agent` > package, its client factories and the `sandbox` methods are #428's > ([its design](https://github.com/Ephemeral-AI-Lab/layerfs/blob/9f97a7ec95b662e9cb288704afa165feff132cfa/core/docs/issues/428/layerfs-agent.md)). There is no > placement since 2026-10-23 (owner): a mount names its Sandbox.
Your project lives in LayerFS, not on your local disk. You read and change it through the SDK, from small Node scripts you run with `node`.
An integration is a host that runs you with a LayerFS project already set up. When it has, its own instructions name the project, how to import the SDK and how to run the `layerfs` command. Use those, and skip [Import the SDK](#import-the-sdk), [Connect to a project](#connect-to-a-project) and `LayerFS.init`:
`LayerFS.open(<project>)` needs nothing else.
module script. A static `import` of a variable is a syntax error.
Nothing there helps, and the SDK is the only way in.
Files you find there may be an old copy, not the project. Do all work on the project through the SDK: `fs.*` and Workspaces for files and commands, and `project.*` and `branch.*` for versioning, as you would use git.
`layerfs project list_branches` or `layerfs fs read <branch> <path>`. Use it for single steps and an SDK script for anything more.
Workspace stays mounted, and its Sandbox never closes. To clear idle, clean leftovers, see [Clearing idle Workspaces](references/methods/workspace.md#clearing-idle-workspaces). End every script with `await layerfs.close()`, in a `finally` block too.
don't write, edit, mount or commit to it. Those calls, and `branch.list_commits("main")`, are refused with `NoSuchBranch`. Fork a Branch, work there, and publish it. A new project's `main` is empty.
Every tool call an agent makes is one **step**, and every step that changes files becomes a Commit on the agent's Branch. The Branch's history is the record of what the agent did, step by step.
| Agent tool | LayerFS calls | Recorded as | | --- | --- | --- | | File read: read, list, search, diff | `fs.read`, `fs.list`, `fs.grep`, `fs.glob`, `fs.diff_files` | Nothing: reads don't change history | | File change: write, edit, many-file change | `fs.write`, `fs.edit`, `fs.apply`, `fs.mkdir`, `fs.mv`, `fs.cp`, `fs.rm` | One Commit per call. Atomic: the whole change lands, or nothing does | | Bash | A Workspace per call: `workspace.mount` → `workspace.exec` → `workspace.commit` → `workspace.unmount` | One Commit with everything the command changed: sources, lockfiles, `node_modules`, build output |
Two ways in: **`fs.*` for cheap, targeted file work; a Workspace for Bash commands**, which often change files too, and for file work too heavy for single calls.
Use `fs.*` for the reads and small changes your own file tools make: read a file, list a folder, search, diff, write or edit one file, move or delete a path, or a handful of related changes as one Commit (`fs.apply`).
Workspace or kernel mount, so it avoids the Bash mount lifecycle. A change is atomic and is exactly one Commit with your message, so the Branch records each edit as its own step. A read returns the Branch's latest Commit, so it sees what every Workspace and every other writer has committed.
or deleting a path.
with `HeadMoved` and nothing is written. Read the file again, then redo your change.
Use a Workspace to run Bash commands. Most of them change files as well, and all of those changes are recorded:
the lockfile), builds (`dist/`), code generators, formatters, `git`, tests that write snapshots or coverage. The Commit holds everything the command changed.
sed -i …`, a scaffolder, unpacking an archive), where one command beats many `fs.*` calls.
conflict markers after a Commit merge ([resolving confli
Website: Hosted Hub: Detailed reference: docs/reference.md 中文版本: README.zh.md Git for the AI era. Mainline lets agents save developer intent and decisions to Git alongside the code. Git already records the history of the code.
Use Mainline's Git-native repository memory while working in a LayerFS project.
Use for coding-agent work in Git repos that use or may need Mainline, or when users mention Mainline, intents, agent autonomy,…