{"record":{"id":"3d5aa3f52ea1424b","repo":"garrytan/gstack","slug":"usage-browse-tab-each-command-args-example","errorCode":null,"errorMessage":"Usage: browse tab-each <command> [args...]\nExample: browse tab-each snapshot -i","messagePattern":"Usage: browse tab-each <command> \\[args\\.\\.\\.\\]\nExample: browse tab-each snapshot -i","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/meta-commands.ts","lineNumber":314,"sourceCode":"\n    case 'closetab': {\n      const id = args[0] ? parseInt(args[0], 10) : undefined;\n      await bm.closeTab(id);\n      return `Closed tab${id ? ` ${id}` : ''}`;\n    }\n\n    case 'tab-each': {\n      // Fan out a single command across every open tab. Returns a JSON\n      // object: { results: [{tabId, url, title, status, output}], total }.\n      // Restores the originally active tab when done so the user's view\n      // doesn't shift under them.\n      //\n      // Usage: $B tab-each <command> [args...]\n      //   $B tab-each snapshot -i      → snapshot every tab\n      //   $B tab-each text             → grab clean text from every tab\n      //   $B tab-each goto https://x.y → load the same URL in every tab\n      if (args.length === 0) {\n        throw new Error(\n          'Usage: browse tab-each <command> [args...]\\n' +\n          'Example: browse tab-each snapshot -i'\n        );\n      }\n\n      const innerRaw = args[0];\n      const innerName = canonicalizeCommand(innerRaw);\n      const innerArgs = args.slice(1);\n\n      // Scope check the inner command before fanning out, so a single\n      // permission failure aborts the whole batch instead of partially\n      // mutating tabs.\n      if (tokenInfo && tokenInfo.clientId !== 'root' && !checkScope(tokenInfo, innerName)) {\n        throw new Error(\n          `tab-each rejected: subcommand \"${innerRaw}\" not allowed by your token scope (${tokenInfo.scopes.join(', ')}).`\n        );\n      }\n","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/meta-commands.ts#L296-L332","documentation":"Thrown by the 'tab-each' meta-command when called with zero arguments. tab-each fans out a single inner command across all open tabs, so it requires at least the inner command name plus optional arguments.","triggerScenarios":"Calling 'browse tab-each' with an empty args array.","commonSituations":"User runs tab-each without specifying which command to fan out, or a script constructs the command with an empty arguments list.","solutions":["Provide the inner command and its arguments, e.g., 'browse tab-each snapshot -i' or 'browse tab-each text'","Consult the usage example in the error message for valid patterns"],"exampleFix":"# before\n$B tab-each\n\n# after\n$B tab-each snapshot -i","handlingStrategy":"validation","validationCode":"if (args.length === 0) {\n  throw new Error('tab-each requires a command. Example: tab-each snapshot -i');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always specify the inner command when calling tab-each","Reference the usage example in the error message for valid command patterns"],"tags":["browse","cli","tabs"],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}