I run SaaS products for German golf clubs. Solo founder. 85 containers, 24 databases, one server. No team.
My AI agents handle deployments, database migrations, code reviews, content pipelines, and infrastructure monitoring. They run autonomously, 24/7. And they make mistakes.
At 2 AM on a Tuesday, one of my agents pushed a hotfix directly to the production branch. No review. No tests. No human in the loop. The app stayed up by luck. I woke up to a commit I never approved on a branch that should be protected.
That morning, I wrote a guard. Two months later, 211 rules have crystallized from 1,448 autonomous agent sessions. Not one of them was planned. Every single rule started as a failure.
Most AI agent setups have no memory. Every session starts from zero. Your agent breaks something on Monday, learns nothing, and breaks the same thing on Wednesday.
I tried prompt engineering. I tried longer system prompts. I tried telling the agent "never push to main." It worked until it did not. Prompts are suggestions. Agents interpret them. Sometimes they interpret them wrong.
What I needed was not better instructions. I needed a system that physically prevents the same mistake from happening twice.
Every skill in my system has a learnings.md
file. When an agent runs a skill and something goes wrong (or right, in a surprising way), the learning gets captured with context, a rule, and a quality score from 1 to 5.
## 2026-06-10: Agent pushed directly to main at 02:14
**Context:** Autonomous deploy task, develop branch was
behind main, agent decided to "shortcut" the workflow
**Learning:** Agents will find creative workarounds when
the intended path has friction
**Rule:** Block git push to main/master/production at the
shell level, not the prompt level
**Score:** 5
**Runs:** 1
On subsequent sessions, when that skill runs again, the agent reads learnings.md
first. If the learning helps, the run counter goes up. If it does not apply, it stays.
When a learning reaches a quality score of 4 or higher AND has proven useful across 3 or more sessions, it crystallizes. It graduates from a soft note in a markdown file to a permanent guard rule: a bash script that fires on every command, every file edit, or every session end.
The learning stops being advice. It becomes law.
Here is the actual main_push_guard.sh
that crystallized from that 2 AM incident:
#!/bin/bash
hook_main_push_guard() {
echo "$CMD_SHELL" | grep -qE \
'git[^;&|]*push([[:space:]]|$)' || return 0
if echo "$CMD_SHELL" | grep -qE \
'push[^;&|]*(main|master|production)'; then
echo "| $(date +%Y-%m-%d\ %H:%M) \
| Main-Push-Guard | blocked \
| $SESSION_ID |" \
>> /opt/audit/gate-audit-log.md
deny "MAIN-PUSH-GUARD: Direct pushes to main \
are blocked. Use: gh pr create"
fi
}
No prompt can override this. No creative agent reasoning can work around it. The deny
function kills the command before it executes. It fires on every git push
across every session, every agent, every skill.
The guard that came from PII leaking into container logs works the same way. An agent dumped a database query result that contained email addresses into stdout. The PII scanner now runs on every command output, checking for email patterns, phone numbers, and German address formats. It does not ask the agent to be careful. It blocks the output.
The loop itself is enforced by a guard. After every skill execution, learnings_loop_guard.sh
fires:
hook_learnings_loop_guard() {
echo "$CMD" | grep -qE 'skills/.*SKILL\.md' \
|| return 0
local skill=$(basename "$skill_dir")
local learnings="/root/.claude/skills/$skill/learnings.md"
if [ -f "$learnings" ]; then
add_context "LEARNINGS-LOOP: Skill '$skill' detected. \
REQUIRED: (1) Read learnings.md BEFORE execution, \
(2) AFTER: increment runs if learning helped, \
add new learning only for NEW insights, \
(3) Check crystallization (Score>=4 + Runs>=3)."
fi
}
The agent is reminded every single time. Read the learnings. Update the counters. Check if anything is ready to crystallize. This is not optional. The guard injects the instruction into the agent's context.
The Crystallization Loop is the R in what I call GRIP:
Guards prevent known failures. 176 guard files fire on every shell command, every file edit, every session end. 96% of all rules are enforced by hooks, not prompts.
Resilient means the system learns from failures it could not prevent. The Crystallization Loop turns agent mistakes into permanent guards. 211 rules crystallized so far. None were written proactively.
Isolated means every customer has their own database. One breach affects one club. Deletion is DROP DATABASE. No shared risk.
Public means full transparency. Every guard block is logged. Every AI feature is documented. Every model choice is traceable.
The feedback loop between G and R is what makes it work. Guards prevent known problems. When unknown problems slip through, they become learnings. When learnings prove stable, they become new guards. The system gets stricter with every session.
My agents have an 88% success rate across 1,448 autonomous sessions. That means 12% still fail.
And that is fine.
Those failures are the fuel. Every failed session is a potential new learning. Every learning that proves itself becomes a permanent rule. If the success rate ever hit 100%, the Crystallization Loop would stop producing new guards. The system would stop getting better.
I do not optimize for zero failures. I optimize for zero repeated failures.
The difference matters. A system that never fails is fragile because it was never tested. A system that fails, captures the failure, and makes it structurally impossible to repeat is antifragile. It gets stronger under stress.
61 skills in the system. Each one has its own learnings file. 73 active learnings are sitting in various stages of the loop right now. Some will crystallize next week. Some will fade because they were too specific to one situation.
232 cron jobs run daily. 17,812 knowledge files in the vault. The agents operate in this environment around the clock, and every interaction with the system is a chance to discover a new edge case that no human would have anticipated.
I did not design most of this. I designed the loop. The loop designed the rules.
You do not need 85 containers to start. You need three things:
learnings.md
file next to your agent configurationStart with the prompt version. When you get tired of agents ignoring the prompt, graduate to shell hooks. That is exactly the path I took.
The book covers the full system: the GRIP framework, the guard architecture, the Crystallization Loop, and how to build autonomous agent operations as a solo founder.
Get the book: Paperback (24.99 USD) https://amazon.com/dp/B0HDMVKRMG | E-Book (9.99 USD) https://amazon.com/dp/B0HDMK7QJ1