{"record":{"id":"61e91f76cca3bc75","repo":"rtk-ai/rtk","slug":"opencode-plugin-is-global-only-use-rtk-init-g","errorCode":null,"errorMessage":"OpenCode plugin is global-only. Use: rtk init -g --opencode","messagePattern":"OpenCode plugin is global-only\\. Use: rtk init -g --opencode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hooks/init.rs","lineNumber":416,"sourceCode":"            anyhow::bail!(\"--codex cannot be combined with --opencode\");\n        }\n        if claude_md {\n            anyhow::bail!(\"--codex cannot be combined with --claude-md\");\n        }\n        if hook_only {\n            anyhow::bail!(\"--codex cannot be combined with --hook-only\");\n        }\n        if matches!(patch_mode, PatchMode::Auto) {\n            anyhow::bail!(\"--codex cannot be combined with --auto-patch\");\n        }\n        if matches!(patch_mode, PatchMode::Skip) {\n            anyhow::bail!(\"--codex cannot be combined with --no-patch\");\n        }\n        run_codex_mode(global, ctx)?;\n    } else {\n        // Validation: Global-only features\n        if install_opencode && !global {\n            anyhow::bail!(\"OpenCode plugin is global-only. Use: rtk init -g --opencode\");\n        }\n\n        if install_cursor && !global {\n            anyhow::bail!(\"Cursor hooks are global-only. Use: rtk init -g --agent cursor\");\n        }\n\n        if install_windsurf && !global {\n            anyhow::bail!(\"Windsurf support is global-only. Use: rtk init -g --agent windsurf\");\n        }\n\n        if install_windsurf {\n            run_windsurf_mode(ctx)?;\n        } else if install_cline {\n            run_cline_mode(ctx)?;\n        } else {\n            // Mode selection (Claude Code / OpenCode)\n            match (install_claude, install_opencode, claude_md, hook_only) {\n                (false, true, _, _) => run_opencode_only_mode(ctx)?,","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/hooks/init.rs#L398-L434","documentation":"rtk's `rtk init` requires agent integrations like the OpenCode plugin to be installed globally. Running `rtk init --opencode` without the -g/--global flag is refused because the plugin must live in the user-level config, not a per-project one. The error message tells the exact command to run instead.","triggerScenarios":"Running `rtk init --opencode` (or any variant where `install_opencode` is true and `global` is false) in the non-codex branch of HooksInit::run. Fires before any files are written.","commonSituations":"A developer initializes hooks per-project as a habit and adds --opencode the same way. Following older docs that did not mark the plugin as global-only. Copying a setup script run in a project directory without the -g flag.","solutions":["Add the -g flag: `rtk init -g --opencode`","If a per-project install was intended, note that the OpenCode plugin does not support it; install globally once instead","Remove --opencode if the global requirement is unacceptable and rely on the default hook setup"],"exampleFix":"// before\nrtk init --opencode\n// after\nrtk init -g --opencode","handlingStrategy":"validation","validationCode":"const opencode = args.includes(\"--opencode\");\nconst global = args.includes(\"-g\") || args.includes(\"--global\");\nif (opencode && !global) throw new Error(\"OpenCode plugin is global-only; add -g\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass -g when installing agent plugins like --opencode or cursor hooks","Treat plugin integrations as user-level (one-time global) setup, distinct from per-project hook init","Read the error message hint: rtk prints the exact corrected command to run"],"tags":["cli","validation","global-scope","opencode"],"backgroundTag":"invalid-cli-argument","analyzedSha":"0924356b4caba4989607227b7c8824d3d8098719","analyzedAt":"2026-09-19T19:25:29.612Z","contentChangedAt":"2026-09-19T19:25:29.612Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}