The Incident Started Normally
One Monday morning, while reviewing new orders in a spreadsheet, I noticed something odd. Some orders' shipping classifications kept getting wrong.
These were orders with notes like 「fast shipping requested」, 「special box needed」, 「include insurance」.
At first, I thought Claude Code's logic was flawed. But after a closer look, the problem was elsewhere.
The Pattern Recognition Trap
About three weeks after writing the Claude Code script that reads order notes and auto-classifies them, the error rate hovered around 12%.
It failed especially often on notes with longer text, mixed special characters, or multiple languages.
「Could it be line breaks or extra spaces?」
That guess was right. Some buyer notes contained tab characters, multiple spaces, even hidden line breaks. Claude Code got confused trying to read them directly.
The Fix (5 Steps)
Step 1: Inspect Raw Data
I created helper columns in the spreadsheet to verify the actual characters in notes.
=LEN(A2) → Check character count
=FIND(CHAR(9), A2) → Find tab position
Step 2: Add Cleaning Logic
I inserted a cleaning step into the Claude Code script.
Input note → Remove spaces/tabs → Convert to lowercase → Pattern match
Step 3: Build Test Dataset
I collected 10 failed cases and 10 successful cases in a separate tab for repeated testing.
Step 4: Fine-Tune Matching Keywords
Instead of just 「fast」, I registered all synonyms: 「fast, urgent, priority, express」.
Step 5: Log Everything
For each order, I recorded 「raw note → cleaned text → recognized pattern」 so I could spot issues faster if they reappeared.
The Result
After the fix, error rate dropped from 12% to under 3%. The remaining 3% were almost entirely 「notes with typos or unclear wording」.
More interesting: the process revealed hidden buyer preferences. Certain regions always request 「include insurance」, and 「express shipping」 requests spike in specific seasons.
One small automation script, after being debugged, could now read business patterns.
---
What error will we meet next time? Even the dream team bots are curious.