Skip to content

docs: Add database protection warning to CLAUDE.md#31

Merged
evansenter merged 1 commit into
mainfrom
docs/database-protection
Jan 1, 2026
Merged

docs: Add database protection warning to CLAUDE.md#31
evansenter merged 1 commit into
mainfrom
docs/database-protection

Conversation

@evansenter

Copy link
Copy Markdown
Owner

Summary

  • Adds prominent warning section to CLAUDE.md about database protection
  • Documents that ~/.claude/contrib/analytics/data.db contains irreplaceable historical data
  • Lists forbidden operations (DROP TABLE, DELETE FROM user tables, file deletion)
  • Lists safe operations (DELETE FROM patterns, make uninstall/reinstall)
  • Notes that tests use temporary databases

Test plan

  • Verified no existing code can drop the database
  • All 205 tests pass

🤖 Generated with Claude Code

Add prominent warning section making clear that the database
contains irreplaceable historical data and must never be dropped.
Documents what operations are safe vs. forbidden.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude

claude Bot commented Jan 1, 2026

Copy link
Copy Markdown

PR Review: docs: Add database protection warning to CLAUDE.md

Summary

This PR adds a prominent warning section to CLAUDE.md that protects the database from accidental deletion. This is excellent documentation that will help prevent future data loss.

Feedback

Strengths:

  1. Well-placed: The warning is positioned prominently after the Architecture section, making it visible to anyone reading the file
  2. Clear categorization: The distinction between "NEVER" and "Safe operations" is helpful and actionable
  3. Accurate documentation: Verified against the codebase:
    • DELETE FROM patterns is indeed the only delete operation in storage.py (lines 921, 924)
    • All 5 test files use tmpdir/tmp_path fixtures for temporary databases
    • The git_commits table exists in the schema (line 491)
  4. Emoji warning: The ⚠️ emoji is appropriate here as it draws attention to critical safety information

Minor suggestions (non-blocking):

  1. Consider adding session_commits to the list of protected tables in the "NEVER" section, since it's also user data (stores session-to-commit mappings):

    - Add `DROP TABLE` statements for `events`, `sessions`, `ingested_files`, `git_commits`, or `session_commits`
  2. The "If you need to test destructive operations" section could optionally mention that pytest automatically handles this through the existing fixtures.

Verification

  • The DELETE FROM statements in storage.py only target patterns table
  • No os.remove(), unlink(), or DROP TABLE for user data exists in the codebase
  • All tests use temporary databases via tmpdir/tmp_path

Verdict

LGTM - This is valuable documentation that will help protect irreplaceable user data. The minor suggestion about session_commits is optional and can be addressed in a follow-up if desired.

@evansenter evansenter merged commit b321729 into main Jan 1, 2026
3 checks passed
@evansenter evansenter deleted the docs/database-protection branch January 1, 2026 22:43
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