There is an app that makes $380K a month in subscriptions. Its code is public on GitHub, and so is CLAUDE.md, the rules file it gives to Claude Code.
Follow that file's history and you see that most rules were added on the same day a real incident was fixed. There is a more interesting part, though: the areas fixed most often have no rules at all.
In this post we cover, in order:
- What Postiz is, and what CLAUDE.md is
- The whole setup: asking (CLAUDE.md) versus enforcing (settings.json)
- The day each rule appeared, and the bug behind it
- What the team missed
- Where to put a lesson
- Fixing the same bugs in a small app of the same shape
- Do rules actually help? Five runs each
How to read the numbers. [Official] means records from the Postiz repository or material published by companies such as Anthropic and Stripe. [Our measurement] means numbers we counted or ran ourselves. [Community report] means user reports or values from third-party sites. All numbers were checked on November 8, 2026.
1. Postiz and CLAUDE.md
According to TrustMRR, a site that verifies revenue by connecting to a company's payment account, Postiz has an MRR (monthly recurring revenue) of $387,731 and 11,400 active subscriptions [Community report] (TrustMRR). The product is open source, and the commit history shows three core developers.
Postiz is a social media scheduling app. You write a post and put it on a calendar. At the set time a background job (a workflow) wakes up and publishes it to more than 28 channels such as X, Instagram, LinkedIn and YouTube. Because it posts to other people's platforms for a subscription fee, customers leave the moment a platform connection or billing breaks.
Claude Code is an AI agent that reads and edits code from the terminal. CLAUDE.md is a plain text file in the project folder that Claude Code reads when it starts work [Official] (Claude Code memory docs). Think of it as the onboarding note you hand a new teammate.
2. The whole setup: asking versus enforcing
At the top of the Postiz repository there is a .claude folder, and a little lower, CLAUDE.md.
CLAUDE.md holds roughly five things [Official] (CLAUDE.md):
- A map: under
appslive the backend, the orchestrator (background jobs) and the frontend; shared code lives inlibraries. Without it, an agent creates code in the wrong folder or rebuilds features that already exist. - Patterns: the backend goes Controller → Service → Repository, with "no shortcuts." Agents in a hurry often call the database straight from a controller, which skips permission and input checks entirely.
- Rules born from production incidents: covered in section 3.
- Rules that say "ask first"
- A PR verification procedure: write steps a reviewer can follow to check the change
.claude/settings.json is short. It is all deny. It blocks every way of reading .env, one by one: not just Read and Edit but cat, head, tail and vim too [Official] (settings.json).
Why block only this? A rule written in a document is a sticky note. The agent usually follows it, but it can forget in a long session. A permission setting is a locked door: the system refuses the moment the agent tries [Official] (Claude Code settings docs). A secret only has to leak once, so they used a lock, not a note. This distinction comes up throughout this post.
3. The day each rule appeared
CLAUDE.md was created on January 30 and has eleven commits on the main branch [Official] (commit history). On day one it held only the map and the patterns, with no operational rules. In other words, they did not imagine rules in advance.
After that, a line was added each time something broke: a security fix, the .env block, a workflow fix, a change to a query function, the introduction of tests, response leaks and the billing webhook. Put the date each rule was added next to the date a bug in the same area was fixed, and they nearly overlap. Some of these pairings are our inference from matching dates.
Workflows: never edit a deployed sequence
A workflow is the step list for a long job that can span days: receive the post, wait, publish, record the result. Temporal, which Postiz uses, replays the history to find where it left off [Official] (Temporal workflow definition). If a developer inserts a new step in the middle and deploys while a job is waiting, the history no longer matches the new sequence, and the waiting job fails.
So the rule is "once a workflow is on main, don't change it; create a new version," and it states the reason: changing it makes every activity fail. With the reason, the agent can apply the rule to similar cases. Right next to it is a check procedure: new code should look like the existing code, and when done, run another agent to compare for odd patterns.
Shared queries: find every caller before you change one
One shared function that reads organization data is used by the web app, the public API, MCP tools and webhooks. Add a field for the web app and it goes out through the other three as well. So a rule appeared: find every place that uses a shared query before changing it, together with a line saying that exposing a stored field externally is a data exposure decision, so ask first (commit on September 30). It is a question, not a ban. Decisions that need judgment call for a question, not a ban.
Credentials: follow this even if nearby code looks different
A channel row in the database holds not only a name but the token used to access the platform. Return that row as-is and the key to posting from someone else's account goes out in the response. After fixing a channel-delete API and an organization-list API that returned more fields than needed, they added "don't return rows of models that contain credentials as-is" (commit on October 1). It ends with "apply this even if surrounding code looks different." Agents tend to copy nearby code, so the rule tells it in advance to hold the line even next to bad code.
Billing webhooks: catch and log, don't throw
A webhook here is the notice Stripe sends to your server when a customer pays. If Stripe doesn't get a success reply, it sends the same notice again, so the receiver must handle duplicate deliveries [Official] (Stripe webhook docs). If the handler doesn't account for that, one notice can create two subscriptions.
The actual fix PR is titled "guard against duplicate Stripe subscriptions per customer" [Official] (PR #2061). One commit inside it stops an error that happened when a retried webhook tried to cancel an already canceled subscription.
There is one more problem. If an exception is thrown midway through a webhook handler, the first step is saved and the next one never runs. You get a customer with a subscription but no credits: someone who paid and can't use the service. So the rule became "in code called by webhooks, don't throw; catch and log" (commit on October 5), and its last sentence gives the reason: a throwing webhook leaves billing state half applied. Fix the incident, and leave one sentence on why it was dangerous. That is the Postiz way.
4. What the team missed
Tests are always red
The staging branch's CLAUDE.md says that a PR that changes behavior must add or update tests [Official] (staging CLAUDE.md). Tests arrived on September 7, and there are now 97 test files.
Yet of the last 100 test runs, 99 failed and none passed. Every run from October 8 to November 7 was red, and the November 8 run had 26 failing unit test files [Our measurement] (test runs). The rule exists, but once red becomes normal, nobody stops when the light turns red. Commits keep landing between the red runs.
The most-fixed areas never became rules
We grouped this year's 418 fix commits on staging by area, using title keywords [Our measurement].
| Area | Fixes | CLAUDE.md rule lines for the area |
|---|---|---|
| Publishing and retries | 45 | 0 |
| Tokens | 34 | 0 |
| Permissions | 30 | 0 |
Grouping by title keyword is rough, but the direction is clear. Incidents that hurt badly once became rules; incidents that hurt a little dozens of times did not.
Open issues cluster in these same areas [Community report]:
- Tokens: after reconnecting a YouTube channel, the refresh token (the pass used to get a new access token when the old one expires) was lost, so publishing silently fails an hour later (#2233)
- Permissions: a regular user role can invite an admin, reported in July 2025 and still open (#866)
- Duplicate posts: one scheduled post went up on X four times in 17 seconds. The reporter suspects it was resent without checking when the response was slow. The cause is not confirmed (#2375)
Seven gaps
- Red tests have become normal.
- Frequently fixed areas don't become rules.
- The flow where money moves has only one rule.
- Retries create duplicates.
- Security fixes such as path traversal and server-side request forgery didn't become rules.
- The docs exist in two versions: main says the frontend is Vite, staging says Next.js.
- Even irreversible things became rules only after an incident, when revenue was already large.
If you are building a revenue-generating app, block these seven from the start.
5. Where to put a lesson
The same lesson is followed more or less reliably depending on where you put it. Lower rows are lighter; higher rows are more certain but cost more to build [Official] (memory, hooks, commands).
| Place | When to use it |
|---|---|
Permission block (settings.json deny) | Things that must never happen |
| Hooks and tests | Things a machine must catch even if the agent forgets |
| Subagents | Reviews that need judgment, in a separate context |
| Slash commands | Repeated tasks a person starts |
| Skills | Long procedures |
Path rules (.claude/rules) | Knowledge needed only when touching certain folders |
| One line in CLAUDE.md | Knowledge that applies everywhere |
Start with one line, and move it up a rung if it breaks again.
6. Fixing the same bugs in a small app of the same shape
We built a small scheduler app shaped like Postiz. Schedule a post on the calendar and the API takes it; a background publish worker watches the clock and posts to a practice social network server. Like X, the practice server has no idempotency key. On the billing side we didn't connect real Stripe; we only built the part that handles notices of the same shape, sent from code. Then we planted three bugs of the same kinds as the Postiz issues, with every test passing.
Bug 1: the same post four times
When we made the platform respond slowly, the same post went up four times [Our measurement]. The worker sends the post; the platform saves it, but the reply is slow, so the worker's wait time runs out. The worker thinks it failed and sends again. A slow response is not a failure; it is an unknown. Before resending, check whether the post already went up.
On billing, sending the same notice twice produced two subscriptions and 200 credits. One payment, credited twice [Our measurement].
Handing it to Claude Code
As at Postiz, we set up a map file and the .env block from the start. When we deliberately asked it to open .env, it said the permission settings blocked it, and it didn't try a workaround such as cat.
Each bug request had three parts: fix the issue, write a failing test first, and leave a rule so the mistake doesn't come back. Seeing the test fail before the fix matters. A test written after the fix passes from the start, so you can't tell whether it really catches the bug.
The publishing bug was fixed by removing the resend: on a slow response, check whether the post went up and mark it done only if it did. A step that claims the post before sending was added too.
Path rules
The rules landed as files in .claude/rules. List paths under paths at the top, and Claude Code reads the rule only when it touches files in those paths [Official] (memory docs). Put everything in the main CLAUDE.md and the agent reads publishing rules even while fixing billing; split them and each loads only when needed. The content says "a timeout is not a failure but an unknown result," and the last line says "if you change the publish path, add a slow-response test and check how many posts went up." The rule and its check sit together.
The billing bug was fixed by recording processed notice IDs and skipping any already processed, and by wrapping the whole handler in a transaction (a bundle that either fully happens or doesn't happen at all). The state of a subscription without credits disappears. Without being asked, it also pointed out that there was no webhook signature check, so anyone could send a fake notice and get credits. That is correct: real Stripe webhooks must verify signatures [Official] (Stripe webhook docs).
The token leak was fixed by limiting the response to id, name and platform, and it noted that tokens already exposed must be revoked and reissued. The rule file got a line banning SELECT * in queries that build responses, because new table columns would otherwise leak automatically.
A Stop hook: no finishing on red
This blocks the first gap, red becoming normal. A hook is a command the system runs for you when the agent reaches a certain point; Stop is the moment the agent tries to finish. This hook runs pnpm test and exits with code 2 on failure. With exit code 2, the message is passed back to the agent, and it keeps working instead of stopping [Official] (hooks docs).
In a new session we deliberately asked: "change the credit value to 200, don't run the tests, just finish." Reading webhook.ts pulled in the billing.md path rule, and when it tried to finish, the hook ran the tests and 6 failed. It only finished after updating the failing expectations [Our measurement]. If the value had been changed by mistake, though, a person should review the change rather than letting the tests be rewritten.
A rule-audit command: repeated incidents as numbers
The second gap, frequently fixed areas never becoming rules, is hard for people to notice. So we built a command that counts. Put rule-audit.md in .claude/commands and you can call it as /rule-audit [Official] (commands docs). It takes a repository path, counts fix commits and rule lines, reports a table and changes no files.
Run on the real Postiz repository, it found 410 fix commits in the last six months, and reported that the most-fixed folder, libraries, has no dedicated rule [Our measurement]. Same direction as our manual count. Run it once a month and you can see, in numbers, when a small repeated incident should become a rule.
7. Do rules actually help?
We asked for three new features on the app in its starting state, five times each, in a fresh session every time, without rules and with the path rules (Claude Code, sonnet model, 2026-11-08) [Our measurement].
| Request | No rules | With rules |
|---|---|---|
| Add retry to a "publish now" button (pass: exactly one post goes up) | 5/5 | 5/5 |
Handle the invoice.paid billing notice (pass: no exception thrown) | 0/5 | 5/5 |
| Add a channel detail API (pass: no token in the response) | 5/5 | 5/5 |
Retries and token leaks were handled in all five runs even without rules. Current models work out common sense like that on their own. Billing was different. Without rules, all five runs threw an exception for an unknown customer, copying the nearby code, which throws. With rules, none of the five did.
Models already know common sense. Rules pay off when they record promises specific to your app, especially ones that differ from the surrounding code. That is why the Postiz rule says "apply this even if surrounding code looks different."
Takeaways and limits
In short:
- The Claude Code setup of this high-revenue app was not fancy: one file, with rules piled up after each incident, each with its reason.
- You don't need to copy it as-is. For the four things that are hard to undo, money, credentials, external data exposure and running jobs, we recommend putting rules and tests in place before launch.
- For the rest, write one line with the reason when something breaks, and move it up a rung if it breaks again.
- Don't rely on documents alone; block with machines. Use a Stop hook so the agent can't finish on red, and run a rule audit once a month.
Limits:
- Some pairings of rule dates with bug-fix dates are inferred from matching dates.
- Fix counts per area are rough values grouped by commit title keywords.
- The measurement is three tasks, five runs per condition, on our own small practice app. Results may differ with other models, versions or apps.
- Revenue, issue and test-run figures were checked on November 8, 2026. Check the original pages on the day you read this.
Watch the video
The video (in Korean) shows the Postiz settings files and history, and Claude Code fixing the bugs in the practice app, on real screens.
Sources
Postiz (Official)- Postiz repository
- CLAUDE.md (main), CLAUDE.md (staging)
- .claude/settings.json
- CLAUDE.md commit history
- PR #2061: guard against duplicate Stripe subscriptions per customer
- Test runs
- #866 Regular user role can invite an admin
- #2233 Refresh token lost after reconnecting YouTube
- #2375 Four posts on X in 17 seconds
- Anthropic, Claude Code memory (CLAUDE.md and .claude/rules)
- Anthropic, Claude Code settings (permissions)
- Anthropic, Claude Code hooks
- Anthropic, Claude Code slash commands
- Stripe, Webhooks
- Temporal, Workflow definition












