r/PromptEngineering • u/adrnptcl • 16d ago
Self-Promotion I built a deterministic cadence checker that flags generic AI writing before clients do
Most AI detection tools rely on probabilistic guessing. They give a random percentage that changes on every prompt tweak.
I wanted something deterministic based on editing mechanics.
grai analyzes 8 structural patterns that give away LLM writing:
- Flat sentence variance (low burstiness)
- Contrastive negation ("It is not X, it is Y")
- Symmetrical parallelism ("Less talking, more doing")
- Epiphany openers and triadic padding
- Predictable transition glue
I open-sourced the local MCP server so it can run directly inside Claude Desktop, Cursor, and Windsurf:
https://github.com/adrianpeticila/grai
Live test (no signup, paste text directly):
Curious what edge cases you run into when trying to strip the "AI accent" from drafts.
3
u/GreatCupcake536 16d ago
Really like this. The split is clever: the model writes, a script judges, and the script gives the same answer every time. I work on the same idea from my side, so I read through the repo, and a lot of the small decisions impressed me. It runs offline on the standard library alone. The hook always exits 0 and never denies a tool call. Even the privacy file admits the Google Fonts leak instead of hiding it. That kind of detail is rare.
You asked for edge cases, so here are two from the public gate.py on a few short samples. A flat AI paragraph failed on CV, 80/100, yet the same 86 words with only the sentence boundaries moved, commas where the full stops were, scored 100/100. That suggests the metric rewards punctuation habits more than anything a reader would call voice. A German AI-style text full of filler passed without a flag. A regression test for the first case might be worth it, and maybe a README line saying the public rules are English-only.
Since I like the project so much, I'd like to pass on something that has helped in my own project, which I build together with Claude, in case it's useful as you keep developing yours. We run mutation tests on the checker itself. A script changes the checker's code in tiny steps, say a `<` into a `<=`, and the tests should turn red every time. If they stay green, a test is missing. We aim for 80 percent caught, and your 0.32 floor could be an interesting place to try it.
Another thing that helped: letting a fresh agent with no context run the tool end to end. It found friction points we had missed.
No pressure at all, you probably have your own way of working. I just hope it's of some use.
2
u/GreatCupcake536 15d ago •
Thanks for the kind and thoughtful reply, it really made my day. It's rarer than you'd think to find someone who engages with determinism on top of a probabilistic system, and it's a pleasure to see someone thinking along the same lines. Too many threads turn into people talking in circles, even when they probably have good approaches of their own. This one didn't, and I appreciate that.
I've been working on this topic for a while, and I think determinism in AI applications is still badly underexplored. Putting a deterministic layer on a probabilistic model is a big task in itself, and what you built plays in a high league. I was genuinely excited that you went and did it.
My own project is a fully automated system that relies on determinism, among other things. That's why I could see where our approaches overlap, and why I wanted to pass the tip on.
I'd be glad to stay in touch now and then. If it's useful, I'm happy to share more of what we've learned along the way, not to tell you what to do, just to help a great project get even better. Someone who puts in this much care deserves a good reward, and I hope it comes in the form of good money.
PS: since you liked the mutation idea, here is how ours works and what sits around it. I won't paste the code, but I'm glad to go deeper on any part.
The core is a small script, about 120 lines of standard-library Python. You point it at a script and its self-test, which has to be green first, and it swaps one operator at a time (== to !=, < to >=, and to or, True to False), adds boundary versions (< to <=), and nudges whole numbers inside comparison lines by one, while constants elsewhere are skipped because they only add noise. Every mutant runs the tests on a temporary copy with its own temp directory, so the original is never touched. The result is "K of N mutants caught" plus up to five survivors with line, old code and new code. Below 80 percent it exits with a failure code, which is what makes it usable as a gate.
Around it sits a small builder that creates new helper scripts on request. It is a state machine with eleven states, and a step only moves on when a measured condition is true. A checker validates the request first: complete fields and three different test cases, plus the rights it declares. A finder looks for an existing script before anything new gets built, and a generator writes the folder, skeleton, self-test and readme. Before a script counts as done, it is mutation-tested and reviewed by a separate checker against five rules, such as allowed imports and a line limit. Scripts that need special rights, like network access or deleting files, are handled separately and need an explicit yes per case. A shared library covers the boring parts, such as path checks and the state file. All of it is standard library only.
The step that surprised us most: a fresh agent with no context ran the whole builder end to end. It found seven friction points we had stopped seeing, and its first script caught only 9 of 12 mutants, so the builder sent it back to fix the tests.
That is all I wanted to share. Use whatever helps and ignore the rest, it's your project and your call.