Transcript

00:00:00it turns out no amount of tweaking your clawed md will stop the slop getting into your code base
00:00:05things slip through and sometimes agents just completely ignore the rules but luckily the
00:00:09humble linter is here to save us anti-slop are rules for ox lint that reject low evidence and
00:00:15low signal typescripts and javascript patterns so in this video we'll go over how to use these
00:00:20in your project and how they can help your agents produce better quality code
00:00:30so anti-slop are just lint rules that can catch low quality code at its source the repo comes with a
00:00:36long list of different rules to catch things like chain type assertions unknown parameters and unknown
00:00:41returns now you may not agree with all of these rules but the point is not to use them all it's to
00:00:47handpick the ones that match your team's standards and linting is a great way to do this because it's
00:00:53a hard fail on things you want to keep out this can save you tokens and deterministically block the
00:00:59slop any rules to clawed md on the other hand can work but it's easy to circumvent and sometimes the
00:01:05agents just don't follow the rules anyway however linting by contrast is faster and cheaper and more
00:01:11effective at detecting obvious patterns but you're probably thinking so what we've had linters for ages
00:01:16so who cares well not only do these show the errors but they also do a great job of explaining why the
00:01:23error occurred and how to fix it and that is pretty juicy data for your agents to use which is so much
00:01:29better than the typical almost unreadable junk that you get from standard typescript errors so let's
00:01:34jump into a demo to see how all of it works and if you want to stay up to date with open source tools
00:01:40then do me a huge favor and subscribe to better stack so here i've got a file which purposely includes a bunch of
00:01:45errors coming from the limp rules in the anti-slot package here at the top you can see that i've
00:01:50typecast twice first unknown and then second to user typically you might do this when you're getting
00:01:55a response from a jason api but then we can see that we have very descriptive errors on both what
00:01:59the issue is and then how to fix it so for this particular error it says this assertion chain
00:02:05discards type evidence which is true and the solution would be to keep the original precise type or pass
00:02:11untrusted input at its boundary before narrowing it so this would be using something like zod to first
00:02:18guarantee the type safety before moving on you can see another similar example of this as well so here
00:02:22with returning data from a json api and then we're just returning it but json actually does return in any
00:02:29type so here at the function we're returning unknown but this again is a bit of a code smile so it says
00:02:36this function exposes unknown to its caller pass the value at its boundary and return a named domain
00:02:41type so let's run claude and see how it handles all of this so let's just say fix all issues in api
00:02:48client so you can see after running for a few minutes all of the issues have been fixed and the loop here
00:02:54would be that inside package json we call lint calling ox lint source and then we've got our lint
00:03:00config itself including almost all of the rules in this case so the agent would produce the code
00:03:06potentially make the mistakes run lint notice the errors and then repair them and that way you get much
00:03:12better quality code going to production none of the errors we catch with these lint rules are bugs the code
00:03:18could still compile but it's about catching low evidence low quality code early before real bugs are
00:03:24introduced chain casting is a good example say i'm pulling an account back from an api i can cast the
00:03:30response into the shape i'm expecting and that isn't a bug in itself it compiles and everything downstream
00:03:36now thinks created that is a date but of course json doesn't have dates so what actually comes back
00:03:41is a string so the first time anything treats that like a date suddenly we've introduced a bug and
00:03:47normally typescript would have a chance to warn me about this but it doesn't because i threw away the
00:03:51evidence using the cast so this package was created just last week and it runs on the linton package ocx
00:03:59which if you're not familiar is a collection of high performance javascript tools written in rust the
00:04:04linter is benchmarked to be 50 to 100 times faster than es lint which sounds unbelievable and i've been
00:04:10using this on all of my projects over the last few months and honestly would highly recommend it and of
00:04:15course the reaction online has been super positive with some users getting slightly more slop errors than they
00:04:20anticipated so if you want to clean up your code base you can check out the github link down in the
00:04:24description don't forget to subscribe thank you for watching and of course i'll see you in the next one

Key Takeaway

Integrating anti-slop rules into the rust-based oxlint tool deterministically blocks low-quality AI-generated code by giving agents clear, actionable error explanations.

Highlights

  • Anti-slop rules for oxlint reject low evidence and low signal TypeScript and JavaScript patterns.

  • Oxlint runs 50 to 100 times faster than ESLint.

  • Chain type assertions discard type evidence and introduce runtime bugs like treating date strings incorrectly.

  • Linter error messages explain both the cause of the error and how to fix it for AI agents.

  • Oxlint is a high performance JavaScript tool written in Rust.

Timeline

Introduction to Anti-Slop Linter Rules

  • Claude MD configurations fail to completely stop low-quality code from entering codebases.
  • Anti-slop rules for oxlint target low evidence TypeScript and JavaScript patterns.
  • Linting helps AI agents produce better quality code by catching patterns automatically.

Configuring rule files for AI assistants often fails because agents ignore or circumvent instructions. The humble linter provides a hard fail on undesirable patterns. Anti-slop rules reject low signal code structures at the source.

Mechanics and Advantages of Linting Over Prompt Rules

  • The linter repository provides rules to catch chain type assertions and unknown parameters or returns.
  • Linting saves tokens and deterministically blocks unwanted patterns faster and cheaper than prompt rules.
  • Linter error messages explain the root cause and repair steps for AI agents.

Teams handpick rules matching their specific standards rather than adopting all available options. Unlike prompt instructions that agents can bypass, linting provides a fast and cheap hard stop. Detailed error messages give agents precise context to fix the code effectively.

Demonstration of Linter Errors and AI Repair Loop

  • Double typecasting unknowns to specific domain types discards type evidence.
  • JSON returns any types which cause code smells when exposed as unknown to callers.
  • AI agents fix reported issues by running the linter command inside package json.

A demonstration file highlights double typecasting from unknown to user types. The linter flags assertion chains that discard type evidence and suggests using libraries like zod at boundaries. The feedback loop involves the agent writing code, running the linter, reading the descriptive errors, and repairing the mistakes.

Preventing Silent Bugs and Performance Benchmarks

  • Type casting API responses into expected shapes hides missing data transformations like JSON string dates.
  • The oxlint package runs on oxc, a collection of high performance JavaScript tools written in Rust.
  • Oxlint benchmarks between 50 and 100 times faster than ESLint.

None of the caught errors break compilation, but they prevent runtime bugs caused by thrown-away type evidence. The underlying tool, oxc, provides massive performance improvements over traditional linters. Positive online adoption rates demonstrate the effectiveness of cleaning up code bases with these rules.

Community Posts

No posts yet. Be the first to write about this video!

Write about this video