Add DB helper scripts for atomic database updates#1
Open
babkinvanya wants to merge 1 commit intom98:mainfrom
Open
Add DB helper scripts for atomic database updates#1babkinvanya wants to merge 1 commit intom98:mainfrom
babkinvanya wants to merge 1 commit intom98:mainfrom
Conversation
Two Python scripts that let Claude update/read all 6 learning databases with a single Bash call instead of 10+ manual Edit operations per session. - read-db.py: loads all databases + computes due reviews, next session ID - update-db.py: atomic update of all 6 DBs with SM-2 spaced repetition - CLAUDE.md: document script usage with input schema examples - .gitignore: add *.json.tmp for atomic write temp files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
read-db.py— loads all 6 learner databases in one call (replaces 6Readtool calls at session start). Returns combined JSON with computed fields (due_reviews_count,next_session_id,streak_active).update-db.py— atomically updates all 6 databases from a single JSON session report via stdin (replaces 10+Edittool calls at session end). Implements SM-2 spaced repetition algorithm, streak tracking, mastery calculation, and error pattern management.*.json.tmpfor atomic write temp files.Why
After each learning session, Claude was manually editing 6 JSON files with 10+ sequential
Editcalls — often taking longer than the lesson itself. These scripts reduce it to a singleBashcall each for reading and writing, with atomic writes (.tmp+rename) and automatic pre-update backups.Usage
Test plan
read-db.pyoutputs valid JSON with all 6 databases and computed fieldsupdate-db.pycorrectly updates all 6 files from a test session payload.tmp→rename)🤖 Generated with Claude Code