lmgit authoring skill

lmgit is a native lmcode host that exposes Git repositories, branches, commits, status entries, diffs, and audit reports as type-checked LMScript objects while executing Git strictly through argv subprocesses.

Purpose

Use lmgit to inspect working-tree status, audit repository health, enumerate branches, tags, remotes, and commit history, or script dry-run-capable branch, commit, tag, and push workflows from LMScript.

When to use it

Use lmgit when an LMScript program needs typed local Git repository inspection or controlled working-tree mutations with structured report gates. Use lmgh when querying GitHub issues, pull requests, releases, or Actions workflow runs over the GitHub API.

Install

Install the LMScript compiler with npm install -g @lmctl-ai/lmctl and ensure Git 2.20 or newer is available (or set LMGIT_GIT=/path/to/git). Install the pinned lmgit release binary with lmscript install.

npm install -g @lmctl-ai/lmctl
lmscript install github:lmctl-ai/lmgit@v0.2.14
lmgit --version
lmgit --lmcode-schema --json
lmgit --lmcode-signatures

Commands

Load the lmgit schema in an LMScript file, interact with the git and report contexts inside _lmcode_, and run the compiled bytecode with run_lmcode:

schema = load_schema(cli="lmgit" install="github:lmctl-ai/lmgit@v0.2.14");
program = _lmcode_ schema;
let repo = git.open(".");
$return.branch = repo.current_branch();
$return.clean = repo.is_clean();
$return.commits = repo.log(5).len();
end _lmcode_
result = run_lmcode(program);
require(result.ok, "git host failed");
print(json_stringify(result.result));

Inputs and outputs

The git context accepts repository paths or clone URLs via git.open(path) and git.clone(url, dest) and returns a Repo handle. Repo methods query status, branches, commits, tags, remotes, config values, and diffs, or perform writes (checkout, branch_create, commit, push, tag_create).

Every invocation writes a single terminal LMCODE_RETURN_BEGIN and LMCODE_RETURN_END JSON frame containing the program's $return value (or per-part results in builder mode). The report context writes text or JSON finding logs and exits with code 4 on report.fail_if_any().

Safety rules

lmgit invokes git as a separate argv-only process with interactive prompts, terminal color, and pagers disabled, and links no Git library code. Call git.dry_run(true) to make write operations (checkout, branch_create, commit, push, tag_create) record their intent rather than invoking Git.

When LMCODE_INVOCATION_FILE sets dry: true, the SDK skips all host callbacks and returns typed dummy objects without starting any Git process or writing report files. Calling git.dry_run(false) inside bytecode cannot disable invocation-level dry mode.

Worked examples

Run the repository examples to inspect uncommitted changes, recent commits, tags, remotes, or repository health:

lmscript examples/repo-status.lms .
lmscript examples/uncommitted-changes.lms .
lmscript examples/recent-commits.lms . 10
lmscript examples/tags-remotes.lms .
lmscript examples/repo-health.lms .

Errors and exit codes

lmgit exits with code 0 on success. Code 2 indicates CLI usage errors or malformed LMCODE_INVOCATION_FILE metadata. Code 3 indicates bytecode load failure, schema hash mismatch, or runtime Git execution failure. Code 4 indicates an application failure such as report.fail_if_any() with recorded findings or an unreadable bytecode file.

How to verify

Verify the host version, schema bytes, canonical signatures, fake-Git regression suite, and real-Git protocol suite.

lmgit --version
lmgit --lmcode-schema --json > /tmp/lmgit-schema.json
cmp /tmp/lmgit-schema.json schema/lmgit.dsl.json
lmgit --lmcode-signatures
./test.sh
python3 tests/protocol.py build/lmgit