Skip to content

Rebuild rules index at SessionStart when stale#14

Merged
baljanak merged 1 commit intomainfrom
fix/rebuild-index-on-session-start
Apr 11, 2026
Merged

Rebuild rules index at SessionStart when stale#14
baljanak merged 1 commit intomainfrom
fix/rebuild-index-on-session-start

Conversation

@baljanak
Copy link
Copy Markdown
Contributor

Summary

  • The rules index (.claude/rules/decisions.md) only updated when Claude Code's Write tool wrote decision files via PostToolUse
  • Files created outside Claude Code (manual edits, git pull, other tools) left the index stale — this is the root cause of the issue reported
  • Now session_init compares decision file mtimes against the index and regenerates if any are newer

Changes

  • session_init.py: Add _rebuild_index_if_stale() — compares mtimes, regenerates via existing _generate_index(), silently handles errors
  • test_session_init.py: 5 new tests — missing index, stale index, fresh index (no-op), empty decisions, error handling

Test plan

  • All 594 tests pass (make check)
  • ruff, mypy, shellcheck clean
  • Manual: create a decision file outside Claude Code, start a new session, verify index is updated

🤖 Generated with Claude Code

The rules index (.claude/rules/decisions.md) only updated via PostToolUse
when Claude Code's Write tool wrote decision files. Files created outside
Claude Code (manual edits, git pull, other tools) left the index stale.

Now session_init checks if any decision file is newer than the index and
regenerates it before the session begins.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@baljanak baljanak merged commit 778c34d into main Apr 11, 2026
5 checks passed
@baljanak baljanak deleted the fix/rebuild-index-on-session-start branch April 11, 2026 04:06
@baljanak baljanak mentioned this pull request Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant