Skip to content
Agent use cases

Building long-term memory for Claude Code with Git repositories and hooks

The author ditched large Obsidian vaults and vector databases, splitting memory into three Git repositories: "how we work," "what happened," and "raw material." Combined with automated hooks, this setup enables precise context loading, error checking, and automatic write-backs.

Reddit r/ClaudeCode/u/tahayelkenci
Claude CodeGitMarkdown

Added 2026-11-05 · originally published 2026-11-04


Steps

  1. 1Create three independent Git repositories: Repository 1 stores working rules and preferences (broken down into small files by professional skill, including weights and rationale), Repository 2 stores project status and dated logs, and Repository 3 stores raw learning materials.
  2. 2Configure the Session Start hook: pull the repositories, inject core rules, personal identity, and the current project's short-term card (around 3k tokens), and re-trigger after context compaction.
  3. 3Configure the message routing hook: use a lightweight router to read user questions and instruct Claude to load the corresponding skill files.
  4. 4Configure the action interception hook: intercept before writing specific content or executing deployments if the matching skill is not loaded; trigger an "Ask Human" prompt before deploying to production.
  5. 5Configure the post-write validation hook: check for known errors after file writing and have Claude automatically fix them.
  6. 6Configure the On Stop hook: prompt the user to write missing logs if project files have changed without a recorded log.
  7. 7Configure the end-of-task write-back: have Claude append dated logs at the end of a task, update the status, and commit and push to the Git repository.

Ideas for Chinese platforms

This Git-based knowledge repository architecture—which separates working rules from project logs—can be adapted for SOP management in content creator matrices or multi-account operations: split platform publishing rules and historical viral hit review logs into separate repositories, using automated scripts to precisely pull rules at task startup and automatically archive data upon completion.

Copy-ready prompt
Please refer to the following structure to set up my long-term memory system:
1. Read specific skill files from [my working rules repository path] to guide the current task: [current task type].
2. Check the README and logs in [project history repository path] to understand the current project status.
3. At the end of the task, automatically append today's progress, decisions, and rationale to the project log, update the final status and TODOs, and commit to Git.
#AI Agent#Claude Code#Memory Management#Git
Troubleshooting and slimming down MCP memory leaks and cache invalidation for AI agents like Claude Code

Addresses the 8MB/16MB crashes, schema bloat, and prompt cache invalidation issues encountered when using the Model Context Protocol (MCP) with tools like Claude Code and OpenAI Codex CLI, utilizing open-source tools for MCP slimming, configuration auditing, and cache miss troubleshooting.

Compress Claude Code context and manage agent skills with tq-forge

To address the high token consumption of resident skill definitions and model compatibility issues in Claude Code, developers built the open-source tool tq-forge. It enables lossless context compression, structured scoring, model compatibility checks, and automated skill generation from user intent, reducing resident tokens from 7,337 to 3,121.

One-click cross-platform short video publishing to TikTok, Reels, and Shorts with Claude Code

Leverage the open-source Cross Post Video Skill to let your AI Agent automatically check video files before uploading, generate platform-specific copy, confirm account-specific settings, and compile a publishing schedule. All pre-checks run locally, with support for tools like Claude Code, Codex, and Cursor.

Found this useful? Get daily updates on Telegram or X.

Found this useful? Buy me a coffee ☕

nebu.life is free to use. If it helped you, a small tip keeps it going. Payments go straight to the author's personal account; this site never handles any funds.

Summarized by AI from the original source - refer to the original post for details. Copyright belongs to the original author.

nebu.lifeNebula AI Playbook · Daily AI use cases, prompts and prices

Content is collected daily from public sources and summarized with AI. Every entry links to the original, and copyright stays with the original authors. Spotted an error or a rights issue? Let us know via the contact page.

Last updated 2026-11-14 07:16 (Beijing time)