{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/hooks/init.rs","lineNumber":298,"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":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/rtk-ai/rtk/blob/d977e1c31621fe8704e6500ceeb9c7a0de2b6836/src/hooks/init.rs#L280-L316","documentation":"The OpenCode plugin is installed into user-level OpenCode config (not a per-project file), so rtk init requires the global flag for it. The validation at src/hooks/init.rs:298 bails when install_opencode is set and global is false, and the message embeds the exact corrective command: `rtk init -g --opencode`.","triggerScenarios":"`rtk init --opencode` without -g/--global — e.g. running init inside a project directory expecting a local install; the flag parses, but the global-only check fails before installation.","commonSituations":"Following generic install docs while sitting in a repo; users assuming all integrations are project-local like the default Claude Code mode; scripted setup that passes --opencode unconditionally but -g only sometimes.","solutions":["Run it as the message says: `rtk init -g --opencode`","If you wanted project-local setup, use the default mode instead: `rtk init` (installs Claude Code hooks/CLAUDE.md locally)","Note the same rule for other global-only targets (cursor, windsurf) before combining flags"],"exampleFix":"# before (inside a project dir)\nrtk init --opencode\n# OpenCode plugin is global-only. Use: rtk init -g --opencode\n\n# after\nrtk init -g --opencode","handlingStrategy":"validation","validationCode":"bash:\n# OpenCode plugin installs user-level: require -g up front\nif [[ \"$*\" == *--opencode* && \"$*\" != *-g* && \"$*\" != *--global* ]]; then\n  echo \"OpenCode plugin is global-only — rerunning with -g\" >&2\n  set -- -g \"$@\"\nfi\nrtk init \"$@\"","typeGuard":"rust:\nfn opencode_invocation_valid(opencode: bool, global: bool) -> bool {\n    !opencode || global\n}","tryCatchPattern":"bash:\nrtk init --opencode 2>err.txt || {\n  grep -q 'global-only' err.txt && exec rtk init -g --opencode\n}","preventionTips":["Memorize the trio of global-only targets: opencode, cursor, windsurf — always pass -g","Default `rtk init` (Claude Code) is the project-local option; use that inside repos","Batch global-only agents into one `rtk init -g` call"],"tags":["init","opencode","global","usage","plugin-install"],"backgroundTag":null,"analyzedSha":"d977e1c31621fe8704e6500ceeb9c7a0de2b6836","analyzedAt":"2026-08-16T05:40:46.291Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}