midudev/autoskills · error · Error

failed

Error message

${label} failed: ${result.stderr.trim() || "unknown error"}

What it means

runGit is a generic wrapper that runs a git command via spawnSync, capturing stdout/stderr, and throws `${label} failed: <stderr>` when git exits non-zero. It backs operations like sparse clones and checkouts during skill materialization; the label tells you which git step died.

Solutions

  1. Re-run with --verbose if available, or run the same git command manually to see full stderr
  2. Upgrade git to a recent version (sparse-checkout needs >=2.25)
  3. Check credentials for the remote (GITHUB_TOKEN / git credential helper) if the failure is auth-related
  4. Verify the configured branch exists on the remote

Example fix

// before
$ git --version # git version 2.17 — no sparse-checkout
// after
$ brew install git # or apt upgrade git → >=2.25
Defensive patterns

Strategy: try-catch

Validate before calling

// verify git version supports the features used (sparse-checkout needs >=2.25)
import { execSync } from "node:child_process";
const v = execSync("git --version", { encoding: "utf8" }).match(/(\d+)\.(\d+)/);
if (Number(v[1]) < 2 || (Number(v[1]) === 2 && Number(v[2]) < 25)) {
  throw new Error("git >= 2.25 required for sparse-checkout");
}

Try / catch

try {
  await syncSkills(opts);
} catch (err) {
  if (err.message.includes("failed:")) {
    console.error(`git step failed: ${err.message}`);
    // classify: auth → fix credentials; network → retry; old git → upgrade
  } else throw err;
}

Prevention

When it happens

Trigger: Any runGit(...) call where the spawned git exits with status !== 0 — e.g. `git clone --depth 1 --filter` fails on network/auth, `git sparse-checkout set` unsupported by old git, checkout of a nonexistent branch.

Common situations: Old local git (<2.25) lacking sparse-checkout support; cloning a private repo without credentials; network interruption mid-clone; branch name in config doesn't exist on the remote.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of midudev/autoskills@0ec725320d (2026-09-15). Data as JSON: /api/errors/82d1519dd911df2b. Report an issue: GitHub.

Appendix: source

Thrown at packages/autoskills/scripts/sync-skills.mjs:333

  const r = spawnSync("tar", ["-xzf", tarFile, "-C", destDir], {
    stdio: FLAGS.verbose ? "inherit" : "pipe",
  });
  if (r.status !== 0) {
    throw new Error(`tar extract failed (status ${r.status})`);
  }
  const entries = readdirSync(destDir);
  const root = entries.find((e) => statSync(join(destDir, e)).isDirectory());
  if (!root) throw new Error(`Empty tarball in ${destDir}`);
  return join(destDir, root);
}

function runGit(args, label) {
  const result = spawnSync("git", args, {
    encoding: "utf-8",
    stdio: ["ignore", "pipe", "pipe"],
  });
  if (result.status !== 0) {
    throw new Error(`${label} failed: ${result.stderr.trim() || "unknown error"}`);
  }
  return result.stdout;
}

function materializeSkillsFromSparseClone(repo, branch, skillNames, destRoot) {
  const repoDir = join(destRoot, "repo");
  runGit(
    [
      "clone",
      "--depth",
      "1",
      "--filter=blob:none",
      "--sparse",
      "--branch",
      branch,
      `https://github.com/${repo}.git`,
      repoDir,
    ],

View on GitHub (pinned to 0ec725320d)