{"record":{"id":"a658dbd9d14529b1","repo":"pbakaus/impeccable","slug":"unknown-command","errorCode":null,"errorMessage":"Unknown command: {}\n","messagePattern":"Unknown command: (.+?)\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/context/src/pin.rs","lineNumber":227,"sourceCode":"        }\n    }\n    serde_json::from_str(COMMAND_METADATA_JSON).unwrap_or(serde_json::Value::Object(Default::default()))\n}\n\npub fn run(args: &[String], io: &mut Io) -> i32 {\n    let action = args.first().cloned();\n    let command = args.get(1).cloned();\n    let (Some(action), Some(command)) = (action.filter(|a| !a.is_empty()), command.filter(|c| !c.is_empty())) else {\n        io.out(\"Usage: impeccable pin <pin|unpin> <command>\\n\");\n        io.out(&format!(\"\\nAvailable commands: {}\\n\", VALID_COMMANDS.join(\", \")));\n        return 1;\n    };\n    if action != \"pin\" && action != \"unpin\" {\n        io.err(&format!(\"Unknown action: {}. Use 'pin' or 'unpin'.\\n\", action));\n        return 1;\n    }\n    if !VALID_COMMANDS.contains(&command.as_str()) {\n        io.err(&format!(\"Unknown command: {}\\n\", command));\n        io.err(&format!(\"Available commands: {}\\n\", VALID_COMMANDS.join(\", \")));\n        return 1;\n    }\n    let cwd = io.cwd.to_string_lossy().into_owned();\n    let root = find_project_root(&cwd);\n    if action == \"pin\" {\n        let metadata = load_metadata(io);\n        let harness_dirs = find_harness_dirs(&root);\n        let opencode_commands_dirs = find_opencode_commands_dirs(&root, io, false);\n        if harness_dirs.is_empty() && opencode_commands_dirs.is_empty() {\n            io.out(\"No harness directories with impeccable installed found.\\n\");\n            return 0;\n        }\n        let mut created = 0;\n        // OpenCode is handled separately below because its shortcut format is\n        // a slash command, not a SKILL.md. Excluding it from the skill loop\n        // prevents a duplicate `.opencode/skills/<cmd>/SKILL.md` that OpenCode\n        // would never surface as `/<cmd>`.","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/context/src/pin.rs#L209-L245","documentation":"The `pin` helper command validates that the command argument names a known command before pinning or unpinning it. If the command string is not in VALID_COMMANDS, it prints the unknown command name plus the list of available commands and exits with status 1. This guards the pinned-commands metadata file from containing garbage entries.","triggerScenarios":"Running the pin subcommand (action pin/unpin) with a command argument that is not in the VALID_COMMANDS list, e.g. a typo like `pin 'searchk'` or a command from a different tool.","commonSituations":"Typo in the command name; passing a command that exists in another crate but is not pin-aware; scripting the pin command with a variable that is empty or stale; version drift where a command was renamed or removed.","solutions":["Check the printed 'Available commands:' list and re-run with an exact valid command name.","Verify the command is actually supported by this version of the tool (renames happen between versions).","If pinning from a script, validate the command name against VALID_COMMANDS before invoking."],"exampleFix":"// before\npin 'serach-files'\n// after\npin 'search-files'  # name taken from the 'Available commands:' output","handlingStrategy":"validation","validationCode":"const VALID_COMMANDS = require('./crates/context/src/pin').VALID_COMMANDS; // or hardcode the printed list\nif (!VALID_COMMANDS.includes(cmd)) {\n  throw new Error(`pin: unknown command '${cmd}'. Valid: ${VALID_COMMANDS.join(', ')}`);\n}","typeGuard":"const isValidCommand = (cmd) => typeof cmd === 'string' && VALID_COMMANDS.includes(cmd);","tryCatchPattern":"const code = run(io); // inspect io.err output for 'Unknown command:'\nif (code === 1 && io.errBuffer.includes('Unknown command:')) {\n  // re-parse the 'Available commands:' line and retry with a corrected name\n}","preventionTips":["Copy command names from the 'Available commands:' output verbatim","Keep pin scripts in sync with version changes to VALID_COMMANDS","Assert the command variable is non-empty and expected before invoking"],"tags":["cli","validation","command-not-found"],"backgroundTag":"invalid-enum-value","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}