Logs you can hand to an AI: building Agent Idea.
We wanted to read every product’s logs from one place, and to let Claude read them too, without any personal data leaving. That took two tools: a logger that refuses personal data, and a service that cleans up whatever gets through.
The problem
Logs are where personal data leaks. An email in an error message, a token in a URL, a full request body dumped while debugging. Once it is in the logs, it is copied to wherever the logs go. We wanted to point an AI assistant at our logs to help find bugs, so the bar was higher: nothing personal could reach it at all.
So we built two layers. The logger stops personal data being written. Agent Idea cleans what is read. Either one alone would leave a gap.
Layer one: a logger that refuses personal data
@ideasquared/log is modelled on Monzo’s slog. Its rules are enforced by TypeScript and at run time, not by a style guide:
- the message must be a fixed string, so
log.info(`sent to ${email}`)is a type error; - every service declares the fields it may log, and anything else is dropped;
- declaring a field such as
email,phone,iportokenthrows when the logger is created; - field values must be plain strings, numbers or booleans, so nobody dumps a whole object.
const log = createLogger({
service: 'creatorgrid-api',
fields: ['accountId', 'platform', 'count', 'requestId'],
});
log.info('sync processed', { platform: 'youtube', count: 3 });
Every ideaSquared repo carries the same logging guide for Claude Code, and CI fails if server code calls console directly.
Layer two: Agent Idea
Agent Idea is a Cloudflare Worker with a command-line tool, idea. When you ask for a product’s logs, it:
- asks GitHub, with your own token, whether you are in that product’s team;
- fetches the logs from Cloudflare Workers Logs, GitHub Actions, Loki or GlitchTip;
- keeps only fields on an allowlist and drops the rest: bodies, headers, cookies, IP addresses;
- scrubs the message for tokens, API keys, emails, phone numbers, postcodes and card numbers;
- turns ids into anonymous tags, so you can follow one user through the logs without knowing who they are.
The sanitiser fails closed: anything it doesn’t recognise is dropped. Even search only looks at sanitised events, so a search can’t reveal whether some hidden email is in the raw logs.
Built in a day, fixed for a week
The first version went in on 14 November: the access-gated API, the sanitiser, Workers Logs, the idea CLI, the logger package, GitHub Actions logs and Loki and GlitchTip for AdoptDontShop. The same day, review found three gaps in the sanitiser, and we closed them before anything else shipped.
That set the pattern. Each gap found later became a fix and a new line in the sanitiser’s test file. On 21 November, a focused review found more: Stripe keys, keys ending in _KEY, emails with non-English letters, emails written with decomposed accents, escaped quotes and whole Authorization values. All are now redacted, and all are tested.
Access had its own lesson. GitHub answers “403” both when you are not in a team and when you have hit a rate limit. The first meant “deny”. The second must not, or a busy afternoon locks everyone out. We fixed both on 21 November.
Letting Claude read the logs
idea mcp runs a small MCP server on your own machine, so Claude Code can read logs as tools, signed in as you. It talks only to the Agent Idea API, never to a log source. The team check and the sanitiser still run on the server, so Claude only ever sees what a person would see.
idea logs creatrgrid --level error --since 24
idea runs pairflix --failed
idea errors ads --frames
What we learned
- Two layers beat one clever one. The logger makes the sanitiser’s job small. The sanitiser catches what the logger can’t, such as text inside an error message.
- Every leak becomes a test. The sanitiser’s test file is a list of every kind of leak we have found so far.
- “Denied” and “try later” are different answers. Treating them the same fails in one direction or the other.