pbakaus/impeccable · error

usage: close <resolved-target> <snapshot-file>

Error message

usage: close <resolved-target> <snapshot-file>

What it means

The `close` subcommand requires exactly two arguments — a resolvable slug-or-target and a bare snapshot filename (no path separators, a valid snapshot name ending in `__<slug>.md` for one of the target's slugs). Any violation prints this usage line and exits 1.

Source

Thrown at crates/context/src/critique_storage.rs:615

                }
            }
            if format_is_json {
                let mut m = Map::new();
                m.insert("snapshot_file".into(), Value::String(jsp::basename(&latest.path)));
                m.insert("body".into(), Value::String(latest.body.clone()));
                io.out(&format!("{}\n", json_pretty(&Value::Object(m))));
            } else {
                io.out(&latest.body);
            }
            0
        }
        "close" => {
            let slug_arg = rest.first().map(String::as_str).unwrap_or("");
            let snapshot_file = rest.get(1).map(String::as_str);
            let slugs = slug_candidates(rest.first().map(String::as_str), &cwd);
            let snapshot_file_ok = snapshot_file.map(|s| !s.is_empty()).unwrap_or(false);
            if slugs.is_empty() || !snapshot_file_ok || rest.len() > 2 {
                io.err("usage: close <resolved-target> <snapshot-file>\n");
                return 1;
            }
            let snapshot_file = snapshot_file.unwrap();
            if jsp::basename(snapshot_file) != snapshot_file
                || !is_snapshot_name(snapshot_file)
                || !slugs.iter().any(|slug| snapshot_file.ends_with(&format!("__{}.md", slug)))
            {
                return 2;
            }
            let snapshot_path = jsp::join(&[&get_critique_dir(&cwd, &env), snapshot_file]);
            let md = match std::fs::symlink_metadata(&snapshot_path) {
                Ok(m) => m,
                Err(_) => return 2,
            };
            if !md.is_file() {
                return 2;
            }
            let Some(snapshot) = read_snapshot_at(&snapshot_path) else {

View on GitHub (pinned to 2bc2879276)

Solutions

  1. Pass the snapshot's basename only, not a path: `close <target> <timestamp>__<slug>.md`.
  2. Provide exactly two arguments, no extras.
  3. Ensure the snapshot filename's `__<slug>.md` suffix matches the first argument's slug (check with `critique-storage slug <target>`).
  4. Verify the slug resolves: an empty/unresolvable first argument also triggers this usage error.

Example fix

// before
close ./app.tsx .impeccable/critiques/20260907T120000__apptsx.md
// after
close ./app.tsx 20260907T120000__apptsx.md
Defensive patterns

Strategy: validation

Validate before calling

const base = path.basename(snapshotFile);
if (base !== snapshotFile || !/__[^_]+\.md$/.test(base)) {
  throw new Error('pass the snapshot basename ending in __<slug>.md, not a path');
}
const extra = args.length - 2;
if (extra > 0) throw new Error('close takes exactly two arguments');

Prevention

When it happens

Trigger: Running `close` with fewer than two arguments, more than two arguments, an empty snapshot-file argument, a snapshot file given as a path (e.g. `dir/snap__slug.md`), or a filename whose slug suffix does not match the target's slugs.

Common situations: Copy-pasting the full path from the `write` output instead of the basename; accidentally passing frontmatter metadata or flags as extra args; mixing snapshots from a different slug than the given target.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of pbakaus/impeccable@2bc2879276 (2026-09-08). Data as JSON: /api/errors/302b02ddd5a265ec. Report an issue: GitHub.