2026
Skill and hooks that keep AI from breaking SAP forms
Static analysis tools and hooks that fire before saving, keeping an AI assistant from leaving SAP Business One form files unreadable for the ERP.
- Python
- Claude Code
- Análisis estático
- Hooks
- Automatización
Problem
SAP Business One forms are XML files in UTF-16 LE with BOM. Any tool that rewrites the file as UTF-8, or drops the BOM along the way, produces something that still looks like XML but the ERP can no longer read. The failure does not show up on save or at compile time: it shows up when a user opens that screen. An AI assistant editing those files multiplies that class of error, because it edits fast and does not look back.
Solution
I wrote a set of static analysis tools plus hooks that fire on their own before a save, so nobody has to remember to run them.
There are four checks: preserve the file's original encoding, validate that every control carries its mandatory attributes, detect duplicate identifiers and block the save when an import is missing. All of it is resolved by reading the file, with no SAP session and no compilation.
Reading cost was a separate problem. These files are long, and reading one in full to change three lines eats context that is needed later for the actual work. The tools return surgical summaries containing the relevant part, at 4.3% of the cost of reading the whole file.
Architecture
AI assistant
|
| read write
+---------------+ |
| | v
v v Pre-save hook
surgical summary full file |
(4.3% of cost) v
Static analysis
+------------------+-----------+------------------+
| | | |
v v v v
encoding mandatory unique ids imports
UTF-16 LE + BOM attributes complete
| | | |
+------------------+-----+-----+------------------+
|
pass <----+----> fail
| |
v v
file written save blockedWhy it is built this way
The hooks fire on their own. A validation you have to invoke by hand ends up never being invoked, and I know because the first versions were commands and nobody ran them.
If an import is missing or an identifier is repeated, the file is not written. Warning did not work: the warning gets read and ignored.
It is all static analysis. Nothing starts SAP and nothing compiles, so a check takes as long as reading the file takes.
By default it returns a summary, and the whole file only on request. Context spent reading is context missing later for reasoning.
The rules are deliberately conservative. A validator that cries wolf gets switched off, and then it validates nothing.
Result
Measured over a four-day pilot: 95.7% less consumption on reads, 0 false positives across 80 runs and one real defect caught before it reached the compiler.
Contact
Let's work together on your next project
If you have a SAP Business One project, a pending integration or simply a question, send me a message. I reply to everything.
- Location
- Palma, Mallorca
- in/ramon-artigues
- GitHub
- RamonArtigues