Design by Contract and effects are essential for LLM-generated code
You feed specifications to an LLM, it spits out an implementation, and you ask it to write tests to verify the behavior. You will not find machine-written prose on this blog. I consider it deeply disrespectful.Design-by-ContractDesign-by-Contract (DbC) is language/syntax feature that allows writing preconditions, postconditions, and invariants (always-true) as part of the signature of methods and structs/classes.It's somewhere between a mix of ad-hoc testing and formal specification.
- ▪You feed specifications to an LLM, it spits out an implementation, and you ask it to write tests to verify the behavior.
- ▪You will not find machine-written prose on this blog.
- ▪I consider it deeply disrespectful.Design-by-ContractDesign-by-Contract (DbC) is language/syntax feature that allows writing preconditions, postconditions, and invariants (always-true) as part of the signature of methods and structs/classes
Hacker News (AI / LLM) files mainly under ai. We currently carry 3,280 of its stories.
Story provenance
Source · retrieval · rights · ranking — open for full record
inspect →
Story provenance
Attribution is not the same as permission. This drawer separates discovery metadata, excerpts, WeSearch-generated summaries, reuse status, and whether the publisher receives the visit. Nothing here claims a legal grant the publisher has not made.
Record
| Original publisher | Gavin Ray Blog |
| Canonical URL | https://gavinray97.github.io/blog/design-by-contract-and-effects-for-llms |
| Publication time | Sun, 02 Aug 2026 21:05:18 +0000 |
| Retrieval time | 2026-08-02T21:20:41.152Z |
| Last seen | 2026-08-02T21:20:41.152Z |
| Headline source | Publisher (no WeSearch rewrite) |
| Excerpt source | publisher body |
| Excerpt method | First ~120 words (~800 chars) of extracted publisher body, fair-use limited. |
| Summary | WeSearch · cerebras-chat (WeSearch summarizer) |
| Summary source text | contentText |
| Citation coverage | Summary is a WeSearch-generated derivative; primary citation is the original publisher URL. |
| Cluster | iekocJ5KePOx · 1 stories |
| Cluster logic | Grouped by semantic title/content similarity across sources within a rolling window. Same-publisher template collisions are excluded from coverage comparison. |
| Ranking reason | Story pages are not engagement-ranked. Hub feeds use recency, with optional source-diversified chronological ordering (cap consecutive stories per source). No personalized ranking. |
| Publisher visit | Yes — open original |
| Substitutes article? | No — link-out required for full text |
Rights status (four layers)
WeSearch handling by dimension
| Indexing | May the item be indexed (stored, ranked, made findable)? | Allowed |
| Snippet | May a short excerpt of the publisher's text be shown? | Allowed |
| AI summary | May WeSearch generate its own short summary of the article? | Limited |
| Retrieval / RAG | May the content be exposed for third-party retrieval-augmented generation? | Not asserted |
| Model training | May the content be used to train AI models? | Not asserted |
| Commercial reuse | May the content be reused commercially? | Not permitted |
Basis: Derived from the published RSS/Atom feed. Contact: [email protected]. Reviewed: 2026-07-24.
Opening excerpt (first ~120 words) tap to expand
Published onSunday, August 2, 2026Design by Contract and effects are essential for LLM-generated codeAuthorsNameGavin RayTwitter@GavinRayDevIn this post, I want to discuss two language features that I think have become substantially more important as software development shifts from human-authored to LLM-authored code.Like many others, the majority of the code I have "written" (prompted) and shipped in the last year was not authored by me. You feed specifications to an LLM, it spits out an implementation, and you ask it to write tests to verify the behavior.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at Gavin Ray Blog.