{"record":{"id":"9ba5c1a571d7ee32","repo":"rtk-ai/rtk","slug":"uninstall-only-works-with-global-flag-for-local-9ba5c1","errorCode":null,"errorMessage":"Uninstall only works with --global flag. For local projects, manually remove RTK from AGENTS.md","messagePattern":"Uninstall only works with --global flag\\. For local projects, manually remove RTK from AGENTS\\.md","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/hooks/init.rs","lineNumber":874,"sourceCode":"        for item in removed {\n            println!(\"  - {}\", item);\n        }\n        if !dry_run {\n            println!(\"\\nRestart Claude Code, OpenCode, and Cursor (if used) to apply changes.\");\n        }\n    }\n\n    if dry_run {\n        print_dry_run_footer();\n    }\n\n    Ok(())\n}\n\nfn uninstall_codex(global: bool, ctx: InitContext) -> Result<()> {\n    let InitContext { dry_run, .. } = ctx;\n    if !global {\n        anyhow::bail!(\n            \"Uninstall only works with --global flag. For local projects, manually remove RTK from AGENTS.md\"\n        );\n    }\n\n    let codex_dir = resolve_codex_dir()?;\n    let removed = uninstall_codex_at(&codex_dir, ctx)?;\n\n    if removed.is_empty() {\n        println!(\"RTK was not installed for Codex CLI (nothing to remove)\");\n    } else {\n        let header = if dry_run {\n            \"[dry-run] would uninstall RTK for Codex CLI:\"\n        } else {\n            \"RTK uninstalled for Codex CLI:\"\n        };\n        println!(\"{}\", header);\n        for item in removed {\n            println!(\"  - {}\", item);","sourceCodeStart":856,"sourceCodeEnd":892,"githubUrl":"https://github.com/rtk-ai/rtk/blob/d977e1c31621fe8704e6500ceeb9c7a0de2b6836/src/hooks/init.rs#L856-L892","documentation":"The Codex CLI integration writes to the global ~/.codex config (AGENTS.md instructions), so its uninstaller is also global-only; a project AGENTS.md is never auto-edited. Same policy as the general uninstall bail, but names AGENTS.md as the manual-edit target.","triggerScenarios":"`rtk uninstall --codex` without `--global` — uninstall_codex at src/hooks/init.rs:876.","commonSituations":"Repos that keep their own AGENTS.md; users assuming uninstall touches a project file that rtk never wrote.","solutions":["Run `rtk uninstall --global --codex`","If a project AGENTS.md contains RTK instructions you added, remove that block manually"],"exampleFix":"# before\nrtk uninstall --codex\n\n# after\nrtk uninstall --global --codex","handlingStrategy":"validation","validationCode":"# bash: codex uninstall always needs --global\nrtk uninstall --global --codex --dry-run   # preview removals first","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pair --codex with --global in scripts","Remember rtk never wrote your project AGENTS.md — clean it by hand if you copied instructions there"],"tags":["cli","uninstall","codex","agents-md"],"backgroundTag":null,"analyzedSha":"d977e1c31621fe8704e6500ceeb9c7a0de2b6836","analyzedAt":"2026-08-16T05:40:46.291Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}