Skip to main content
๐Ÿ’ป๐Ÿ—๏ธ๐Ÿงช๐Ÿ›๐Ÿ“„communitySource: aicode.swerdlow.deveveryone

AI Code

6 min read1,192 words

Be intentional about how AI changes your codebase.

As AI Coding Agents write more code, it's more important than ever that we're intentional about the code it writes.

> "The only thing that sloppifies a codebase faster than 1 coding agent is a swarm of them"

This document serves as a manifesto and guide for all humans working with AI Coding agents on how the code AI writes should look. It's also available as a skill you can give your AI Agents.

npx skills add theswerd/aicodeAdd to Cursor โ†—%20to%20retrywithexponentialbackoffandrunyinbetween%3CY%3A%20func%2C%20X%3A%20Func%3E(x%3A%20X%2C%20y%3A%20Y).%20Even%20if%20these%20functions%20are%20never%20used%20again%2C%20future%20humans%20and%20agents%20going%20over%20the%20code%20will%20appreciate%20the%20indexing%20of%20information.%0A%0ASemantic%20functions%20should%20not%20need%20any%20comments%20around%20them%2C%20the%20code%20itself%20should%20be%20a%20self%20describing%20definition%20of%20what%20it%20does.%20Semantic%20functions%20should%20ideally%20be%20extremely%20unit%20testable%20because%20a%20good%20semantic%20function%20is%20a%20well%20defined%20one.%0A%0APragmatic%20Functions%0A%0APragmatic%20functions%20should%20be%20used%20as%20wrappers%20around%20a%20series%20of%20semantic%20functions%20and%20unique%20logic.%20They%20are%20the%20complex%20processes%20of%20your%20codebase.%20When%20making%20production%20systems%20it's%20natural%20for%20the%20logic%20to%20get%20messy%2C%20pragmatic%20functions%20are%20the%20organization%20for%20these.%20These%20should%20generally%20not%20be%20used%20in%20more%20than%20a%20few%20places%2C%20if%20they%20are%2C%20consider%20breaking%20down%20the%20explicit%20logic%20and%20moving%20it%20into%20semantic%20functions.%20For%20example%20provisionnewworkspaceforgithubrepo(repo%2C%20user)%20or%20handleusersignupwebhook().%20Testing%20pragmatic%20functions%20falls%20into%20the%20realm%20of%20integration%20testing%2C%20and%20is%20often%20done%20within%20the%20context%20of%20testing%20whole%20app%20functionality.%20Pragmatic%20functions%20are%20expected%20to%20change%20completely%20over%20time%2C%20from%20their%20insides%20to%20what%20they%20do.%20To%20help%20with%20that%2C%20it's%20good%20to%20have%20doc%20comments%20above%20them.%20Avoid%20restating%20the%20function%20name%20or%20obvious%20traits%20about%20it%2C%20instead%20note%20unexpected%20things%20like%20%22fails%20early%20on%20balance%20less%20than%2010%22%2C%20or%20combatting%20other%20misconceptions%20coming%20from%20the%20function%20name.%20As%20a%20reader%20of%20doc%20comments%20take%20them%20with%20a%20grain%20of%20salt%2C%20coders%20working%20inside%20the%20function%20may%20have%20forgotten%20to%20update%20them%2C%20and%20it's%20good%20to%20fact%20check%20them%20when%20you%20think%20they%20might%20be%20incorrect.%0A%0AModels%0A%0AThe%20shape%20of%20your%20data%20should%20make%20wrong%20states%20impossible.%20If%20a%20model%20allows%20a%20combination%20of%20fields%20that%20should%20never%20exist%20together%20in%20practice%2C%20the%20model%20isn't%20doing%20its%20job.%20Every%20optional%20field%20is%20a%20question%20the%20rest%20of%20the%20codebase%20has%20to%20answer%20every%20time%20it%20touches%20that%20data%2C%20and%20every%20loosely%20typed%20field%20is%20an%20invitation%20for%20callers%20to%20pass%20something%20that%20looks%20right%20but%20isn't.%20When%20models%20enforce%20correctness%2C%20bugs%20surface%20at%20the%20point%20of%20construction%20rather%20than%20deep%20inside%20some%20unrelated%20flow%20where%20the%20assumptions%20finally%20collapse.%20A%20model's%20name%20should%20be%20precise%20enough%20that%20you%20can%20look%20at%20any%20field%20and%20know%20whether%20it%20belongs%20%E2%80%94%20if%20the%20name%20doesn't%20tell%20you%2C%20the%20model%20is%20trying%20to%20be%20too%20many%20things.%20When%20two%20concepts%20are%20often%20needed%20together%20but%20are%20independent%2C%20compose%20them%20rather%20than%20merging%20them%20%E2%80%94%20e.g.%20UserAndWorkspace%20%7B%20user%3A%20User%2C%20workspace%3A%20Workspace%20%7D%20keeps%20both%20models%20intact%20instead%20of%20flattening%20workspace%20fields%20into%20the%20user.%20Good%20names%20like%20UnverifiedEmail%2C%20PendingInvite%2C%20and%20BillingAddress%20tell%20you%20exactly%20what%20fields%20belong.%20If%20you%20see%20a%20phonenumber%20field%20on%20BillingAddress%2C%20you%20know%20something%20went%20wrong.%0A%0AValues%20with%20identical%20shapes%20can%20represent%20completely%20different%20domain%20concepts%3A%20%7B%20id%3A%20%22123%22%20%7D%20might%20be%20a%20DocumentReference%20in%20one%20place%20and%20a%20MessagePointer%20in%20another%2C%20and%20if%20your%20functions%20just%20accept%20%7B%20id%3A%20String%20%7D%2C%20the%20code%20will%20accept%20either%20one%20without%20complaint.%20Brand%20types%20solve%20this%20by%20wrapping%20a%20primitive%20in%20a%20distinct%20type%20so%20the%20compiler%20treats%20them%20as%20separate%3A%20DocumentId(UUID)%20instead%20of%20a%20bare%20UUID.%20With%20branding%20in%20place%2C%20accidentally%20swapping%20two%20IDs%20becomes%20a%20syntax%20error%20instead%20of%20a%20silent%20bug%20that%20surfaces%20three%20layers%20deep.%0A%0AWhere%20Things%20Break%0A%0ABreaks%20commonly%20happen%20when%20a%20semantic%20function%20morphs%20into%20a%20pragmatic%20function%20for%20ease%2C%20and%20then%20other%20places%20in%20the%20codebase%20that%20rely%20on%20it%20end%20up%20doing%20things%20they%20didn't%20intend.%20To%20solve%20this%2C%20be%20explicit%20when%20creating%20a%20function%20by%20naming%20it%20instead%20of%20by%20what%20it%20does%2C%20but%20by%20where%20it's%20used.%20The%20nature%20of%20their%20names%20should%20make%20it%20clear%20to%20other%20programmers%20in%20their%20names%20that%20their%20behavior%20is%20not%20tightly%20defined%20and%20should%20not%20be%20relied%20on%20for%20the%20internals%20to%20do%20an%20exact%20task%2C%20and%20make%20debugging%20regressions%20from%20them%20easier.%0A%0AModels%20break%20the%20same%20way%20but%20slower.%20They%20start%20focused%2C%20then%20someone%20adds%20%22just%20one%20more%22%20optional%20field%20because%20it's%20easier%20than%20creating%20a%20new%20model%2C%20and%20then%20someone%20else%20does%20the%20same%2C%20and%20eventually%20the%20model%20is%20a%20loose%20bag%20of%20half-related%20data%20where%20every%20consumer%20has%20to%20guess%20which%20fields%20are%20actually%20set%20and%20why.%20The%20name%20stops%20describing%20what%20the%20data%20is%2C%20the%20fields%20stop%20cohering%20around%20a%20single%20concept%2C%20and%20every%20new%20feature%20that%20touches%20the%20model%20has%20to%20navigate%20states%20it%20was%20never%20designed%20to%20represent.%20When%20a%20model's%20fields%20no%20longer%20cohere%20around%20its%20name%2C%20that's%20the%20signal%20to%20split%20it%20into%20the%20distinct%20things%20it's%20been%20coupling%20together.)Code should be self documenting

How you split logic into functions and shape the data they pass around determines how well a codebase holds up over time.

Semantic Functions

Semantic functions are the building blocks of any codebase, a good semantic function should be as minimal as possible in order to prioritize correctness in it. A semantic function should take in all required inputs to complete its goal and return all necessary outputs directly. Semantic functions can wrap other semantic functions to describe desired flows and usage; as the building blocks of the codebase, if there are complex flows used everywhere that are well defined, use a semantic function to codify them.

Side effects are generally undesirable in semantic functions unless they are the explicit goal because semantic functions should be safe to re-use without understanding their internals for what they say they do. If logic is complicated and it's not clear what it does in a large flow, a good pattern is to break that flow up into a series of self describing semantic functions that take in what they need, return the data necessary for the next step, and don't do anything else. Examples of good semantic functions range from quadraticformula() to retrywithexponentialbackoffandrunyinbetweenY: func, X: Func>(x: X, y: Y). Even if these functions are never used again, future humans and agents going over the code will appreciate the indexing of information.

Semantic functions should not need any comments around them, the code itself should be a self describing definition of what it does. Semantic functions should ideally be extremely unit testable because a good semantic function is a well defined one.

Pragmatic Functions

Pragmatic functions should be used as wrappers around a series of semantic functions and unique logic. They are the complex processes of your codebase. When making production systems it's natural for the logic to get messy, pragmatic functions are the organization for these. These should generally not be used in more than a few places, if they are, consider breaking down the explicit logic and moving it into semantic functions. For example provisionnewworkspaceforgithubrepo(repo, user) or handleusersignupwebhook(). Testing pragmatic functions falls into the realm of integration testing, and is often done within the context of testing whole app functionality. Pragmatic functions are expected to change completely over time, from their insides to what they do. To help with that, it's good to have doc comments above them. Avoid restating the function name or obvious traits about it, instead note unexpected things like "fails early on balance less than 10", or combatting other misconceptions coming from the function name. As a reader of doc comments take them with a grain of salt, coders working inside the function may have forgotten to update them, and it's good to fact check them when you think they might be incorrect.

Models

The shape of your data should make wrong states impossible. If a model allows a combination of fields that should never exist together in practice, the model isn't doing its job. Every optional field is a question the rest of the codebase has to answer every time it touches that data, and every loosely typed field is an invitation for callers to pass something that looks right but isn't. When models enforce correctness, bugs surface at the point of construction rather than deep inside some unrelated flow where the assumptions finally collapse. A model's name should be precise enough that you can look at any field and know whether it belongs โ€” if the name doesn't tell you, the model is trying to be too many things. When two concepts are often needed together but are independent, compose them rather than merging them โ€” e.g. UserAndWorkspace { user: User, workspace: Workspace } keeps both models intact instead of flattening workspace fields into the user. Good names like UnverifiedEmail, PendingInvite, and BillingAddress tell you exactly what fields belong. If you see a phonenumber field on BillingAddress, you know something went wrong.

Values with identical shapes can represent completely different domain concepts: { id: "123" } might be a DocumentReference in one place and a MessagePointer in another, and if your functions just accept { id: String }, the code will accept either one without complaint. Brand types solve this by wrapping a primitive in a distinct type so the compiler treats them as separate: DocumentId(UUID) instead of a bare UUID. With branding in place, accidentally swapping two IDs becomes a syntax error instead of a silent bug that surfaces three layers deep.

Where Things Break

Breaks commonly happen when a semantic function morphs into a pragmatic function for ease, and then other places in the codebase that rely on it end up doing things they didn't intend. To solve this, be explicit when creating a function by naming it instead of by what it does, but by where it's used. The nature of their names should make it clear to other programmers in their names that their behavior is not tightly defined and should not be relied on for the internals to do an exact task, and make debugging regressions from them easier.

Models break the same way but slower. They start focused, then someone adds "just one more" optional field because it's easier than creating a new model, and then someone else does the same, and eventually the model is a loose bag of half-related data where every consumer has to guess which fields are actually set and why. The name stops describing what the data is, the fields stop cohering around a single concept, and every new feature that touches the model has to navigate states it was never designed to represent. When a model's fields no longer cohere around its name, that's the signal to split it into the distinct things it's been coupling together.

npx skills add theswerd/aicodeAdd to Cursor โ†—%20to%20retrywithexponentialbackoffandrunyinbetween%3CY%3A%20func%2C%20X%3A%20Func%3E(x%3A%20X%2C%20y%3A%20Y).%20Even%20if%20these%20functions%20are%20never%20used%20again%2C%20future%20humans%20and%20agents%20going%20over%20the%20code%20will%20appreciate%20the%20indexing%20of%20information.%0A%0ASemantic%20functions%20should%20not%20need%20any%20comments%20around%20them%2C%20the%20code%20itself%20should%20be%20a%20self%20describing%20definition%20of%20what%20it%20does.%20Semantic%20functions%20should%20ideally%20be%20extremely%20unit%20testable%20because%20a%20good%20semantic%20function%20is%20a%20well%20defined%20one.%0A%0APragmatic%20Functions%0A%0APragmatic%20functions%20should%20be%20used%20as%20wrappers%20around%20a%20series%20of%20semantic%20functions%20and%20unique%20logic.%20They%20are%20the%20complex%20processes%20of%20your%20codebase.%20When%20making%20production%20systems%20it's%20natural%20for%20the%20logic%20to%20get%20messy%2C%20pragmatic%20functions%20are%20the%20organization%20for%20these.%20These%20should%20generally%20not%20be%20used%20in%20more%20than%20a%20few%20places%2C%20if%20they%20are%2C%20consider%20breaking%20down%20the%20explicit%20logic%20and%20moving%20it%20into%20semantic%20functions.%20For%20example%20provisionnewworkspaceforgithubrepo(repo%2C%20user)%20or%20handleusersignupwebhook().%20Testing%20pragmatic%20functions%20falls%20into%20the%20realm%20of%20integration%20testing%2C%20and%20is%20often%20done%20within%20the%20context%20of%20testing%20whole%20app%20functionality.%20Pragmatic%20functions%20are%20expected%20to%20change%20completely%20over%20time%2C%20from%20their%20insides%20to%20what%20they%20do.%20To%20help%20with%20that%2C%20it's%20good%20to%20have%20doc%20comments%20above%20them.%20Avoid%20restating%20the%20function%20name%20or%20obvious%20traits%20about%20it%2C%20instead%20note%20unexpected%20things%20like%20%22fails%20early%20on%20balance%20less%20than%2010%22%2C%20or%20combatting%20other%20misconceptions%20coming%20from%20the%20function%20name.%20As%20a%20reader%20of%20doc%20comments%20take%20them%20with%20a%20grain%20of%20salt%2C%20coders%20working%20inside%20the%20function%20may%20have%20forgotten%20to%20update%20them%2C%20and%20it's%20good%20to%20fact%20check%20them%20when%20you%20think%20they%20might%20be%20incorrect.%0A%0AModels%0A%0AThe%20shape%20of%20your%20data%20should%20make%20wrong%20states%20impossible.%20If%20a%20model%20allows%20a%20combination%20of%20fields%20that%20should%20never%20exist%20together%20in%20practice%2C%20the%20model%20isn't%20doing%20its%20job.%20Every%20optional%20field%20is%20a%20question%20the%20rest%20of%20the%20codebase%20has%20to%20answer%20every%20time%20it%20touches%20that%20data%2C%20and%20every%20loosely%20typed%20field%20is%20an%20invitation%20for%20callers%20to%20pass%20something%20that%20looks%20right%20but%20isn't.%20When%20models%20enforce%20correctness%2C%20bugs%20surface%20at%20the%20point%20of%20construction%20rather%20than%20deep%20inside%20some%20unrelated%20flow%20where%20the%20assumptions%20finally%20collapse.%20A%20model's%20name%20should%20be%20precise%20enough%20that%20you%20can%20look%20at%20any%20field%20and%20know%20whether%20it%20belongs%20%E2%80%94%20if%20the%20name%20doesn't%20tell%20you%2C%20the%20model%20is%20trying%20to%20be%20too%20many%20things.%20When%20two%20concepts%20are%20often%20needed%20together%20but%20are%20independent%2C%20compose%20them%20rather%20than%20merging%20them%20%E2%80%94%20e.g.%20UserAndWorkspace%20%7B%20user%3A%20User%2C%20workspace%3A%20Workspace%20%7D%20keeps%20both%20models%20intact%20instead%20of%20flattening%20workspace%20fields%20into%20the%20user.%20Good%20names%20like%20UnverifiedEmail%2C%20PendingInvite%2C%20and%20BillingAddress%20tell%20you%20exactly%20what%20fields%20belong.%20If%20you%20see%20a%20phonenumber%20field%20on%20BillingAddress%2C%20you%20know%20something%20went%20wrong.%0A%0AValues%20with%20identical%20shapes%20can%20represent%20completely%20different%20domain%20concepts%3A%20%7B%20id%3A%20%22123%22%20%7D%20might%20be%20a%20DocumentReference%20in%20one%20place%20and%20a%20MessagePointer%20in%20another%2C%20and%20if%20your%20functions%20just%20accept%20%7B%20id%3A%20String%20%7D%2C%20the%20code%20will%20accept%20either%20one%20without%20complaint.%20Brand%20types%20solve%20this%20by%20wrapping%20a%20primitive%20in%20a%20distinct%20type%20so%20the%20compiler%20treats%20them%20as%20separate%3A%20DocumentId(UUID)%20instead%20of%20a%20bare%20UUID.%20With%20branding%20in%20place%2C%20accidentally%20swapping%20two%20IDs%20becomes%20a%20syntax%20error%20instead%20of%20a%20silent%20bug%20that%20surfaces%20three%20layers%20deep.%0A%0AWhere%20Things%20Break%0A%0ABreaks%20commonly%20happen%20when%20a%20semantic%20function%20morphs%20into%20a%20pragmatic%20function%20for%20ease%2C%20and%20then%20other%20places%20in%20the%20codebase%20that%20rely%20on%20it%20end%20up%20doing%20things%20they%20didn't%20intend.%20To%20solve%20this%2C%20be%20explicit%20when%20creating%20a%20function%20by%20naming%20it%20instead%20of%20by%20what%20it%20does%2C%20but%20by%20where%20it's%20used.%20The%20nature%20of%20their%20names%20should%20make%20it%20clear%20to%20other%20programmers%20in%20their%20names%20that%20their%20behavior%20is%20not%20tightly%20defined%20and%20should%20not%20be%20relied%20on%20for%20the%20internals%20to%20do%20an%20exact%20task%2C%20and%20make%20debugging%20regressions%20from%20them%20easier.%0A%0AModels%20break%20the%20same%20way%20but%20slower.%20They%20start%20focused%2C%20then%20someone%20adds%20%22just%20one%20more%22%20optional%20field%20because%20it's%20easier%20than%20creating%20a%20new%20model%2C%20and%20then%20someone%20else%20does%20the%20same%2C%20and%20eventually%20the%20model%20is%20a%20loose%20bag%20of%20half-related%20data%20where%20every%20consumer%20has%20to%20guess%20which%20fields%20are%20actually%20set%20and%20why.%20The%20name%20stops%20describing%20what%20the%20data%20is%2C%20the%20fields%20stop%20cohering%20around%20a%20single%20concept%2C%20and%20every%20new%20feature%20that%20touches%20the%20model%20has%20to%20navigate%20states%20it%20was%20never%20designed%20to%20represent.%20When%20a%20model's%20fields%20no%20longer%20cohere%20around%20its%20name%2C%20that's%20the%20signal%20to%20split%20it%20into%20the%20distinct%20things%20it's%20been%20coupling%20together.)I believe these patterns lead to scalable codebases, and scalable codebases lead to faster iteration cycles and better software.

Or maybe I'm out of date.

By Ben Swerdlow

A human coder who cares about good code

[](https://x.com/benswerd)

Source Attribution
OpenDocs keeps source fields explicit. Unknown values are labeled instead of invented.

Source domain

aicode.swerdlow.dev

Author

Unknown

Publisher

aicode.swerdlow.dev

License / usage

Unknown. Review the original source terms before republishing beyond public-safe excerpts.

Score
Version docs-phase3-2026-05-20
87

Overall quality score, confidence 81%

Source credibility90
Freshness95
Completeness97
Extraction quality75
Attribution confidence90
Readability
difficult | grade 37.3 | format 45

47 sentences, 0 headings, 0 list items.

Add descriptive headings to make the document easier to scan.

Use lists for steps, requirements, or extracted facts when appropriate.

Search Appearance
canonical document page
OpenDocs keeps inspected URLs, canonical URLs, snippets, and rich-result signals explicit; Search Console metrics are not treated as visits.
Social Card
AI Code
Be intentional about how AI changes your codebase. As AI Coding Agents write more code, it's more important than ever that we're intentional about the code...
Duplicate State
No duplicate is asserted on this page without a matching canonical URL or content hash cluster.
Trace
docs-score-4920313b7d8edadc9f6f635b
Export
Use public export endpoints for Markdown/JSON. Protected publishing still requires PLATPHORM_API_KEY.

Related Documentation

๐Ÿ‘ฅ

Chert | iMessage Infrastructure for Reaching People at Scale

Skip to main content https://docs.platphormnews.com/docs/chert imessage infrastructure for reaching people at scale main content Back to docs https://docs.platphormnews.com/docs Skip to content โ†— https://www.trychert.com

7 min read

๐Ÿ‘ฅ

SEO Starter Guide: The Basics | Google Search Central | Documentation | Google for Developers

Skip to main content https://developers.google.com/search/docs/fundamentals/seo starter guide main content Google Search Central English Deutsch Espaรฑol Espaรฑol โ€“ Amรฉrica Latina Franรงais Indonesia Italiano Polski Portugu

22 min read

๐Ÿ‘ฅ

Chert | iMessage Infrastructure for Reaching People at Scale

Skip to content https://www.trychert.com/ main content New Chert is now live on Hacker News Check it out โ†’ https://www.trychert.com/agent Chert https://www.trychert.com/ Home https://www.trychert.com/ Blog https://www.tr

5 min read

๐Ÿš€๐Ÿงช๐Ÿ“–๐Ÿ”โŒ

Three Inverse Laws of AI - Susam Pal

9 min read

๐Ÿ”’๐Ÿ—๏ธ๐Ÿ“„โœจ๐Ÿ”„

GameStop Proposes to Acquire eBay at $125.00 Per Share | GameStop Corp.

GameStop Corp. (NYSE: GME) today submitted a non-binding proposal to acquire 100% of eBay Inc. (NASDAQ: EBAY) at $125.00 per share in cash and stock. The offer represents a 46% premium to eBayโ€™s unaffected closing price on February 4, 2026, the day GameStop started accumulating its position in eBay. GameStop has built a 5% economic stake in eBay through derivatives and beneficial ownership of common stock. GameStop is filing a Schedule 13D and HSR notification tomorrow. The full proposal letter and accompanying materials are available at investor.gamestop.com/ebay . The proposed offer is $125.00 per share, comprising 50% cash and 50% GameStop common stock, with full shareholder election rights as to consideration type and pro-rata allocation. Aggregate undiluted equity value is approximately $55.5 billion, based on eBayโ€™s most recently disclosed undiluted share count, representing a 27% premium to the 30-day VWAP and a 36% premium to the 90-day VWAP. The transaction is conditioned on

11 min read