plandex-ai/plandex · error

no current plan

Error message

no current plan

What it means

WriteCurrentBranch needs a plan id (CurrentPlanId) to locate the per-plan settings directory under ~/.plandex/<projectId>/<planId>. When the current-plan global is empty — no plan is checked out for this account — the branch cannot be attributed to any plan, so it returns 'no current plan'.

Source

Thrown at app/cli/lib/plans.go:110

		return fmt.Errorf("error writing current plan: %v", err)
	}

	CurrentPlanId = ""

	return nil
}

func WriteCurrentBranch(branch string) error {
	if fs.HomePlandexDir == "" {
		return fmt.Errorf("HomePlandexDir not set")
	}

	if CurrentProjectId == "" || HomeCurrentPlanPath == "" {
		return fmt.Errorf("no current project")
	}

	if CurrentPlanId == "" {
		return fmt.Errorf("no current plan")
	}

	dir := filepath.Join(fs.HomePlandexDir, CurrentProjectId, CurrentPlanId)

	err := os.MkdirAll(dir, os.ModePerm)

	if err != nil {
		return fmt.Errorf("error creating plan dir: %v", err)
	}

	path := filepath.Join(dir, "settings-v2.json")

	var settingsByAccount *types.PlanSettingsByAccount

	bytes, err := os.ReadFile(path)
	if err == nil {
		err = json.Unmarshal(bytes, &settingsByAccount)
		if err != nil {

View on GitHub (pinned to e2d772072e)

Solutions

  1. Create or select a plan first (plandex new <plan> or equivalent) so WriteCurrentPlan sets CurrentPlanId, then switch branches.
  2. Re-select the current plan for the logged-in account so the settings file gains an entry for auth.Current.UserId.
  3. In tests, set lib.CurrentPlanId to a valid plan id before calling WriteCurrentBranch.

Example fix

// before
lib.WriteCurrentBranch("feature") // error: no current plan

// after
lib.WriteCurrentPlan(planId) // sets CurrentPlanId
lib.WriteCurrentBranch("feature")
Defensive patterns

Strategy: validation

Validate before calling

if lib.CurrentPlanId == "" {
    return fmt.Errorf("no plan selected; run `plandex new` first")
}
err := lib.WriteCurrentBranch(branch)

Type guard

func hasCurrentPlan() bool { return lib.CurrentPlanId != "" }

Prevention

When it happens

Trigger: Calling WriteCurrentBranch via checkout/new/MustLoadCurrentPlan when lib.CurrentPlanId == '' — i.e. ClearCurrentPlan was run, the plan context was never loaded, or current-plans-v2.json has no entry for auth.Current.UserId.

Common situations: Running 'plandex checkout <branch>' before ever selecting/creating a plan; switching accounts (settings are keyed by user id) so the new account has no current plan; a state file reset by upgrading CLI versions that moved from the old current-plan file to current-plans-v2.json.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/d509c058e3e5eed9. Report an issue: GitHub.