lean-ctx icon indicating copy to clipboard operation
lean-ctx copied to clipboard

bug: `lean-ctx doctor` complains "no rules file found" after upgrading to 3.8.1 and running `lean-ctx setup`

Open teadatuntud opened this issue 5 months ago • 2 comments

lean-ctx version: (run lean-ctx --version) lean-ctx 3.8.1 (official, https://github.com/yvgude/lean-ctx)

OS: (macOS / Linux / Windows) Linux

AI tool: (Cursor / Claude Code / Copilot / Crush / other) Claude Code

What happened: I was on 3.7.3. To upgrade, I ran:

lean-ctx update
lean-ctx setup
lean-ctx doctor

Result:

27/28 passed.

The offending line:

✗  Claude Code instructions  MCP instructions truncated at 2048 chars, no rules file found  (run: lean-ctx init --agent claude)`.

What you expected: lean-ctx doctor to report 28/28 checks passed.

Steps to reproduce:

  1. Run the commands above.

Relevant output:

# Excerpt from the terminal output after running `lean-ctx setup` (note: username was stripped)
  [4/12] Agent Rules
  ─────────────────────────────────────────────────────
  ○ No agent rules needed
Installed Claude Code hooks at /home/<username>/.claude/hooks
Removed /home/<username>/.claude/rules/lean-ctx.md (always-loaded duplicate; the CLAUDE.md block + on-demand skill replace it)
Neovim (mcphub.nvim) MCP already configured at ~/.config/mcphub/servers.json

teadatuntud avatar Jun 12 '26 11:06 teadatuntud

Fixed in 81731b5b8 on main — thanks for the precise report, the setup excerpt made the root cause obvious.

What happened: 3.8 intentionally retired the always-loaded ~/.claude/rules/lean-ctx.md (it duplicated the instructions in every session — users saw 12k+ token memory footprints). lean-ctx setup now maintains a compact <!-- lean-ctx --> block in ~/.claude/CLAUDE.md plus an on-demand skill, and actively removes the legacy rules file — exactly what your setup output shows. The doctor check, however, was never migrated: it still demanded the retired file, so a clean install could not reach a full pass. Worse, the suggested fix (lean-ctx init --agent claude) no longer creates that file either — following it would have looped forever.

The fix: both doctor views (doctor and doctor integrations — the latter had the same stale check) now share a single layout detector that accepts every state setup can produce:

  • CLAUDE.md block + skill (the post-3.8 default — your state)
  • dedicated injection (SessionStart hook + skill, rules_injection=dedicated)
  • a legacy rules file from a pre-3.8 install (still works until the next setup migrates it)
  • rules_scope=project and rules_injection=off (intentional absence)

Only a genuinely missing installation fails now, and the hint points at lean-ctx setup. The docs that still described the rules-file layout were updated in the same commit.

On your machine the next release's lean-ctx doctor will report the line as ✓ Claude Code instructions — CLAUDE.md block + skill installed — no action needed on your side, your install was correct all along; only the check was wrong.

yvgude avatar Jun 12 '26 12:06 yvgude

Fixed in v3.8.2 (released today).

Root cause: the 3.8 layout intentionally replaced the always-loaded ~/.claude/rules/lean-ctx.md with a managed CLAUDE.md block + on-demand skill — lean-ctx setup even removes the legacy rules file. But the doctor check still demanded that file, so a clean 3.8.1 install could never reach a full pass, and the suggested fix (lean-ctx init --agent claude) couldn't recreate it either. You were chasing a check that no current command can satisfy — sorry about that.

Fix (81731b5): both doctor views (lean-ctx doctor and lean-ctx doctor integrations) now share one layout detector that accepts every state setup can produce: CLAUDE.md block (+ skill), dedicated injection (SessionStart hook + skill), the legacy rules file, project-only scope, and rules_injection = off. Docs that still described the retired rules file were updated as well.

After upgrading (lean-ctx update), lean-ctx doctor reports the Claude integration as healthy with the v3 layout — no rules file required. Thanks for the clear report with the exact doctor output!

yvgude avatar Jun 12 '26 15:06 yvgude