# How to Keep AI-Written Code Clean When Nobody Reads It

DevFeed: [How to Keep AI-Written Code Clean When Nobody Reads It](<https://devfeed.tech/articles/how-to-keep-ai-written-code-clean-when-nobody-reads-it-100959.md>)

Original publisher: [Read original article](<https://proandroiddev.com/what-keeps-agent-written-code-clean-when-nobody-reads-it-62b771eb4a50?source=rss----c72404660798---4>)

Author: Ramiz Raja

Published: 2026-10-26T13:37:31Z

Content type: article

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [clean-code](<https://devfeed.tech/topics/clean-code.md>), [context-architecture](<https://devfeed.tech/topics/context-architecture.md>), [mutation-testing](<https://devfeed.tech/topics/mutation-testing.md>), [Pull Request](<https://devfeed.tech/topics/pull-request.md>), [Continuous integration](<https://devfeed.tech/topics/continuous-integration.md>), [Android](<https://devfeed.tech/topics/android.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [ai-agent](<https://devfeed.tech/tags/ai-agent.md>), [ai-coding-agents](<https://devfeed.tech/tags/ai-coding-agents.md>), [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [clean-architecture](<https://devfeed.tech/tags/clean-architecture.md>), [code](<https://devfeed.tech/tags/code.md>), [coding](<https://devfeed.tech/tags/coding.md>), [data](<https://devfeed.tech/tags/data.md>), [domain](<https://devfeed.tech/tags/domain.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [ios](<https://devfeed.tech/tags/ios.md>), [ios-development](<https://devfeed.tech/tags/ios-development.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [layers](<https://devfeed.tech/tags/layers.md>), [review](<https://devfeed.tech/tags/review.md>), [software-architecture](<https://devfeed.tech/tags/software-architecture.md>), [test](<https://devfeed.tech/tags/test.md>), [tests](<https://devfeed.tech/tags/tests.md>)

## AI overview

Written architecture rules alone did not preserve the boundary in ResizePing: a rule checked once allowed media kit imports to spread into 20 UI files and 5 domain files. The author's approach is to enforce important seams with build-failing tests that scan imports, fail if the source root is missing, and are proven against deliberate violations. A grep-based JVM test is a lightweight option for single-module Android apps; separate Gradle modules or Swift packages can make forbidden imports compiler errors. The author also has a different model inspect the repository when reviewing plans and code, and uses shared JSON cases and fixtures to check matching behavior across native Kotlin and Swift implementations. These contracts cover only their defined cases, and changes to the cases need review.

## Source excerpt

AI agents write most of the code in my Android and iOS apps now, and I don't read it line by line. I read plans, verdicts and test results. That leaves a fair question: if nobody reads the code, what keeps the clean architecture clean? Clean architecture with AI coding agents is what keeps the next change cheap. When an SDK changes, I want to touch one adapter, not forty screens. And the next agent should find one obvious place for the next feature. The short answer: written rules don't do it on their own. Boundary tests that fail the build do, plus a second model that reviews the plan and reads the repo instead of trusting the writer. The rest of this piece is the evidence, starting with a boundary that broke. The apps involved are my own: ResizePing (image and video resizing), StatusPing (WhatsApp status saving), PlannedPing (scheduled WhatsApp messages) and ChatPing (a bring-your-own-key AI chat app). All are native Kotlin on Android and Swift on iOS. The rule that lived in a prompt Here's the boundary that broke, because it shows the problem better than anything that held. ResizePing is an image and video resizer. Its engine lives in a shared kit, ping-media-kit, which both the Android and iOS apps consume. The first integration task said the app's domain and UI layers must never import kit types. Everything goes through one app-side repository, so the kit could be replaced later without changing call sites. The independent review that gated that task checked it with a grep: grep -rn com.pingfamily.mediakit app/src/main` returns hits ONLY in `data/resize/EngineGateway.kt` and `data/resize/ResizeRepositoryImpl.kt`. Any hit in `domain/` or `ui/` is a FAIL. It passed. Then the app kept growing: video, combine-to-PDF, export options. I ran the same grep while writing this. It now finds kit imports in 20 files under ui/ and 5 under domain/. The iOS app has the same leak in its video view model. Nobody decided to drop the rule. It was checked once, at one review, and