Avoiding Repeated Corrections Across AI Tools: Separating Principles, Rules, and Notes with Nightly Reflection

Contents
  1. Separating Storage into Three Places
  2. Adapting the OpenClaw Pattern for Multiple Tools
  3. Keeping Corrections in One Place and Searching Reference Notes
  4. Collecting Forgotten Corrections Nightly and Checking After Output
  5. Comparing with Weekly Auto-Trimming and Where This Setup Helps
  6. What Is Worth Adopting Next
  7. Implementation Blueprint for Replicating This Setup
  8. References

Even if you tell Claude Code to avoid a certain phrasing, opening Codex often means repeating the exact same correction. When you switch between several AI tools on one machine, repeating those instructions quickly becomes tiring.

In my current setup, I keep my core writing principles and chat corrections in local plain-text files and load them across tools. Older research notes and URLs stay in a separate searchable log that is not loaded at session start. Every night, an automated job collects corrections I forgot to record during busy sessions and syncs them across tools.

I split storage into three places and run separate update and checking processes alongside them.

Square stick-figure diagram showing four roles supporting multiple AI tools: Soul, Memory / AGENTS.md, Log, and Nightly Reflection, connected by arrows

Separating Storage into Three Places

Putting everything into one configuration file runs into tool-specific loading limits and clutters ordinary conversations with unrelated details. I split storage into three plain-text categories based on how often each changes and when it is needed.

Despite the labels, all three are ordinary text files. At the start of each session, a tool reads only the Soul file, the excerpted Memory file, and a short index of topic notes.

Soul does not define a fictional persona or voice gimmick. It states practical habits—separating facts from inference, keeping source links and file paths, and writing reusable notes—plus a few lines of recurring subject areas. It is excluded from automatic edits so I only revise it by hand.

Adapting the OpenClaw Pattern for Multiple Tools

Hearing names like Soul, Memory, and AGENTS.md will remind many readers of OpenClaw's workspace files. OpenClaw popularized managing an agent with plain Markdown files—SOUL.md for persona and tone, AGENTS.md for operating rules, MEMORY.md for curated long-term memory, memory/YYYY-MM-DD.md for daily logs, and HEARTBEAT.md for periodic checks1,2.

My workflow keeps those core ideas: separating core principles, operating rules, and searchable logs in plain text, and staying quiet unless something actually changed.

Where it diverges is the scope. OpenClaw assumes a single agent workspace, whereas my day-to-day work jumps across Claude Code, Codex, and other tools. To bridge those environments, I added automated excerpt syncing across tools, nightly cross-tool log reflection, and post-response hooks.

OpenClaw's standard workspace vs. my multi-tool adaptation
Role Standard OpenClaw setup This multi-tool setup
Principles SOUL.md defines persona, voice, and boundaries Soul focuses on practical working habits such as keeping sources
Rules & memory AGENTS.md and MEMORY.md serve one agent Appended to one archive; a size-capped excerpt syncs to every tool
Daily notes Loads today + yesterday's daily files; searches older logs Log is never loaded upfront and is searched only on demand
Routine HEARTBEAT.md runs periodic checks and stays silent when idle Nightly job scans all tools for missed feedback and notifies only on change
Output checks Mainly guided by prompt rules and checklists Adds Stop hook scripts to catch recurring phrases right after output

Keeping Corrections in One Place and Searching Reference Notes

Whenever I say in chat to avoid a phrase or follow a specific workflow, I append a dated entry to one archive file. Because that archive grows steadily, no tool should load all of it every time.

Tools also handle instruction files and size caps differently. Claude Code's built-in auto memory loads the first 200 lines or 25KB of MEMORY.md at session start3, while OpenAI Codex applies a default 32KiB budget to project-level AGENTS.md instruction files4.

To handle this, I keep a compact excerpt file alongside the full archive. A sync script pulls recent dated rules into the excerpt and drops older recent items from the excerpt whenever the combined size approaches a tool's limit, while keeping the full history intact in the archive.

For Codex, which does not automatically expand external file references, the same script writes the excerpt into a marked section of AGENTS.md. This removes manual copy-pasting and cuts down on drift between tools.

Reference notes (Log) serve a different purpose: storing facts and URLs rather than behavioral rules. Years of reading notes sit alongside a current log where each line captures content, source, reason for saving, and potential reuse. None of it is loaded at session start; I search across it with rg only when looking up past notes or verifying drafts.

Collecting Forgotten Corrections Nightly and Checking After Output

Even with good intentions, it is easy to give feedback in chat during a busy task and forget to write it down. Switching between tools means those ad-hoc corrections never carry over.

To catch those misses, a nightly scheduled job scans recent conversation logs across all tools for correction cues, passes them to claude -p to extract only unrecorded durable instructions, and syncs updates out. Because a brief chat summary arrives only on nights with changes, it stays out of the way.

Four-stage nightly reflection flow
  1. Collect logsScan recent chats across all tools for correction signals
  2. Distill via claude -pIdentify unrecorded durable rules and recurring issues
  3. Append and syncUpdate the archive, sync excerpts, and queue skill updates
  4. Notify on changeSend a brief summary only on nights with new items

For recurring boilerplate phrases that models still emit despite prompt rules, I add a post-response check using Stop hooks5 in Claude Code and Antigravity. Running a small script right after a response finishes catches specified phrases and prompts a rewrite, reducing misses compared with relying on a long prohibition list alone.

A stick figure seated at a desk under a crescent moon, reviewing three sheets of notes and marking a checkmark in an open notebook

Comparing with Weekly Auto-Trimming and Where This Setup Helps

A November 2026 Japanese blog post on Hatena Anonymous Diary described a different approach: prepare a set of ideal outputs and run claude -p weekly to rewrite CLAUDE.md so it stays as simple as possible while still producing those outputs, opening a pull request each time6. As models and harnesses improve, obsolete rules drop out and the file gets shorter over time.

These two workflows aim at different problems.

Weekly rule-trimming workflow vs. multi-tool shared memory setup
Dimension Weekly trimming (Hatena post) Multi-tool shared memory setup
Core problem Instructions grow stale as models and harnesses change Corrections and notes do not carry over across tools
Source of updates Predefined set of ideal outputs Real chat corrections and accumulated notes
Primary loop Rewrite instructions, compare outputs, open a PR Collect corrections across tools, archive, and sync
Principles & notes Focused on tuning global instructions Core principles in Soul; searchable archive in Log
Boilerplate checks Evaluated against example outputs Additional post-response check via Stop hooks

When working across several AI tools every day, a few practical advantages stand out.

Corrections and notes are never locked inside one product. Feedback given to Claude stays in local text files and carries directly into Codex or another tool.

Keeping full history in the archive while loading only a compact excerpt prevents ordinary chats from getting weighed down. Because Soul stays outside automatic updates, yesterday's minor phrasing tweak never alters baseline principles.

Useful rules accumulate naturally from real work without having to craft a large suite of test examples up front.

Keeping written guidance, step-by-step skills, and Stop hooks separate also makes the setup easier to maintain over time.

What Is Worth Adopting Next

In daily use, repeating the same phrasing correction after switching tools has dropped noticeably. At the same time, the nightly job focuses on adding rules rather than verifying whether older rules are still necessary on newer models.

Dropping a Claude-only weekly auto-trimmer directly onto shared multi-tool rules carries real caveats.

Removing a rule that Claude no longer needs can still break expected behavior in Codex or Antigravity. Any review of shared rules needs to be checked across the main tools you rely on.

Surface similarity to an example answer does not guarantee work quality either. Even when citations and URLs look tidy, comparing prose alone cannot tell whether sources were actually opened or whether unverified claims slipped in.

Nightly additions and weekly deletions can also cancel each other out. If a weekly pass deletes a rule as unnecessary and the nightly job later sees an older correction as unrecorded, the same rule will vanish and reappear in a loop.

A more practical path is to keep the current setup and borrow only the evaluation step from the weekly workflow: maintain a small set of desired examples and run a weekly review that proposes consolidating duplicates or retiring outdated rules via a pull request.

Keeping core principles and the full archive intact—while recording why a rule was retired or merged—prevents the nightly job from re-adding it automatically. Alongside that, I plan to select items for the session excerpt by priority as well as recency.

Implementation Blueprint for Replicating This Setup

If you pass this article's URL (https://shoei05.com/en/articles/3030/) to Claude Code or Codex and ask it to build the same structure on your machine, it can recreate the workflow directly. Below is the minimal generic layout and script specification with all personal settings removed.

1. Folder and File Layout

Keep all shared files and scripts inside one directory (for example, ~/.ai-memory/), then reference or sync them from each tool's configuration file.

~/.ai-memory/
├── SOUL.md                  # Core principles (edited manually, never auto-updated)
├── memory.md                # Full dated archive (- YYYY-MM-DD: ...)
├── ACTIVE_RULES.md          # Session-start excerpt (with an auto-synced recent section)
├── logs/
│   └── notes.md             # Search-only reference notes (never loaded at startup)
├── scripts/
│   ├── sync_rules.py        # Builds the excerpt and syncs it into tool configs
│   ├── reflect_daily.sh     # Nightly cross-tool log scan, append, and notification
│   └── style_guard.py       # Stop hook checking recurring phrases after output
├── reports/                 # Nightly reflection summaries
└── backups/                 # Automatic backups saved before editing memory.md

Append daily corrections to memory.md as one dated line per item (- YYYY-MM-DD: ...). When retiring an older rule, keep it in the archive with a brief reason instead of deleting it so the nightly job does not re-add it later.

Write your permanent baseline rules in ACTIVE_RULES.md and place <!-- AUTO_RECENT_START --> and <!-- AUTO_RECENT_END --> markers at the bottom. The sync script updates only the block between those markers.

Store each reference note in logs/notes.md as one line formatted like "Note" Source | Why it matters | Reuse idea. Keep logs/ out of session-start loading and search it on demand with rg -n "<keyword>" ~/.ai-memory/logs/.

2. Wiring Each AI Tool

Connect SOUL.md and ACTIVE_RULES.md to whichever tools you use on your machine.

  • In Claude Code, add @~/.ai-memory/SOUL.md and @~/.ai-memory/ACTIVE_RULES.md to ~/.claude/CLAUDE.md, and register python3 ~/.ai-memory/scripts/style_guard.py --mode claude under hooks.Stop in ~/.claude/settings.json.
  • In Codex, add <!-- ACTIVE_RULES_SYNC_START --> and <!-- ACTIVE_RULES_SYNC_END --> markers to ~/.codex/AGENTS.md and let sync_rules.py populate SOUL.md and ACTIVE_RULES.md inside Codex's default 32KiB budget.
  • In other tools (such as Antigravity, Cursor, or Gemini CLI), either reference SOUL.md and ACTIVE_RULES.md from the tool's global instruction file or add the same sync markers as a target in sync_rules.py.

Include two shared instructions across every tool: search ~/.ai-memory/logs/ with rg whenever past notes are requested, and append new corrections to memory.md in - YYYY-MM-DD: ... format followed by running sync_rules.py.

3. Specification for the Three Scripts

sync_rules.py (Excerpt Generation and Tool Sync)

Reads dated entries from memory.md and writes the newest items into the AUTO_RECENT block of ACTIVE_RULES.md. Whenever the combined size approaches your tool budget (around 20–24KB), it trims older recent entries from the excerpt while keeping memory.md intact. After updating the excerpt, it writes the same content into the sync marker blocks of files such as ~/.codex/AGENTS.md.

reflect_daily.sh (Nightly Reflection Job)

Runs once every night via launchd on macOS or cron / a systemd timer on Linux. It scans session logs updated within the past 24 hours across installed tools (for example, ~/.claude/projects/*/*.jsonl and ~/.codex/sessions/*/*/*/*.jsonl) and extracts user turns containing correction cues such as "remember", "stop using", "fix this", or "from now on".

Those snippets, along with ACTIVE_RULES.md and recent lines from memory.md, are passed to a command-line model such as claude -p to return only unrecorded durable rules as JSON. If nothing new is found, the script exits quietly. On nights with new rules, it saves a timestamped backup of memory.md in backups/, appends the new entries, runs sync_rules.py, saves a summary under reports/YYYY-MM-DD.md, and optionally sends a short notification (Slack, Telegram, desktop notification, etc.).

style_guard.py (Post-Response Stop Hook)

Reads the hook payload JSON from standard input and inspects the latest assistant message. To prevent infinite rewrite loops, it exits immediately whenever stop_hook_active is true. It strips fenced code blocks, inline code, URLs, and blockquotes before matching against a small regex list of phrases to avoid, and outputs {"decision": "block", "reason": "matched phrases and rewrite guidance"} following Claude Code's Stop hook format when a match is found.

4. Copy-Paste Prompt to Build This Setup

Send the prompt below with this article's URL to Claude Code or Codex so it inspects your OS and installed tools before building the same workflow.

Read https://shoei05.com/en/articles/3030/ and implement the setup described in the implementation blueprint at the end of the article for my machine.

Before making changes, inspect my environment and propose a plan covering:
1. Installed AI tools (Claude Code, Codex, Cursor, Gemini CLI, etc.) and existing rule files
2. How to preserve my existing rules without overwriting them
3. Which scheduler to use for nightly reflection (launchd on macOS; cron or systemd on Linux)

Once I approve the plan, create ~/.ai-memory/, the three scripts, tool wiring, and a minimal verification check.

References

  1. OpenClaw Docs. Agent workspace. https://docs.openclaw.ai/concepts/agent-workspace
  2. OpenClaw Docs. Memory overview. https://docs.openclaw.ai/concepts/memory
  3. Anthropic. How Claude remembers your project (Claude Code Docs). https://code.claude.com/docs/en/memory
  4. OpenAI. Custom instructions with AGENTS.md (ChatGPT Learn). https://learn.chatgpt.com/docs/agent-configuration/agents-md
  5. Anthropic. Hooks reference (Claude Code Docs). https://code.claude.com/docs/en/hooks
  6. Hatena Anonymous Diary. CLAUDE.md / AGENTS.md を Claude Codeに継続的に書かせる. November 26, 2026. https://anond.hatelabo.jp/20261126144022
English translation of the Japanese article.