{"record":{"id":"34906007ea523557","repo":"plandex-ai/plandex","slug":"no-current-project","errorCode":null,"errorMessage":"no current project","messagePattern":"no current project","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/plans.go","lineNumber":20,"sourceCode":"\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"plandex-cli/auth\"\n\t\"plandex-cli/fs\"\n\t\"plandex-cli/types\"\n\t\"sync\"\n)\n\nfunc WriteCurrentPlan(id string) error {\n\tif fs.HomePlandexDir == \"\" {\n\t\treturn fmt.Errorf(\"HomePlandexDir not set\")\n\t}\n\n\tif CurrentProjectId == \"\" || HomeCurrentPlanPath == \"\" {\n\t\treturn fmt.Errorf(\"no current project\")\n\t}\n\n\tvar currentPlanSettingsByAccount *types.CurrentPlanSettingsByAccount\n\n\tbytes, err := os.ReadFile(HomeCurrentPlanPath)\n\tif err == nil {\n\t\terr = json.Unmarshal(bytes, &currentPlanSettingsByAccount)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error unmarshalling current-plans-v2.json: %v\", err)\n\t\t}\n\t} else if !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"error checking if current-plans-v2.json exists: %v\", err)\n\t}\n\n\tif currentPlanSettingsByAccount == nil {\n\t\tcurrentPlanSettingsByAccount = &types.CurrentPlanSettingsByAccount{}\n\t}\n","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/plans.go#L2-L38","documentation":"WriteCurrentPlan requires both a selected project (CurrentProjectId) and a valid HomeCurrentPlanPath; if either is empty it returns 'no current project', meaning there is no project context in which to record the current plan.","triggerScenarios":"Calling `plandex cd <plan>` or `new` outside a project directory / before connecting to a project, so CurrentProjectId is empty or HomeCurrentPlanPath was never set during init.","commonSituations":"Running plan commands outside any Plandex project; corrupted or deleted current-project state file under HomePlandexDir; fresh install where no project was ever created or joined.","solutions":["Run `plandex projects` / connect or create a project first so CurrentProjectId is set","cd into your Plandex project directory before running `cd`/`new`","Re-initialize Plandex in the directory (plandex init) to restore HomeCurrentPlanPath","If state is corrupted, remove the stale current-plan/current-project files under HomePlandexDir and reconnect"],"exampleFix":"// before\n$ cd /tmp && plandex cd myplan\nerror: no current project\n// after\n$ cd ~/my-project && plandex cd myplan","handlingStrategy":"validation","validationCode":"if lib.CurrentProjectId == \"\" || lib.HomeCurrentPlanPath == \"\" {\n\treturn fmt.Errorf(\"no current project: run plandex init inside a project directory first\")\n}\nif err := lib.WriteCurrentPlan(planId); err != nil {\n\treturn err\n}","typeGuard":"func hasProjectContext() bool {\n\treturn lib.CurrentProjectId != \"\" && lib.HomeCurrentPlanPath != \"\"\n}","tryCatchPattern":"if err := lib.WriteCurrentPlan(id); err != nil {\n\tif err.Error() == \"no current project\" {\n\t\t// prompt user to cd into a project / run plandex init\n\t}\n\treturn err\n}","preventionTips":["Run plandex commands from inside a connected project directory","Initialize the project (plandex init) before cd/new","Restore missing current-project state files under HomePlandexDir","Check project context early in CLI entrypoints to fail fast"],"tags":["go","cli","state","project"],"backgroundTag":"missing-project-context","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}