-
Notifications
You must be signed in to change notification settings - Fork 0
[D] Generation AI Services
Code Generation Principles Mapped to AI‑Assisted Service Generation
This document adapts the Non‑Negotiable Principles for Code Generation (with Anti‑Patterns) specifically for AI‑assisted service generation (LLMs, copilots, autonomous agents, prompt‑driven generators).
AI dramatically lowers the cost of producing code, which means it also lowers the cost of producing mistakes.
Without discipline, AI turns architectural debt into a force multiplier.
AI‑assisted generation introduces new risks:
- non‑deterministic output,
- hidden training bias,
- prompt drift,
- loss of authorship and intent,
- false confidence in syntactically correct but semantically wrong code.
Therefore:
AI must be treated as a generator, not a developer.
Prompts are templates. You must own and control them.
- Prompts stored in version control
- Prompts reviewed like code (PRs, approvals)
- Explicit prompt versions pinned to generated artifacts
- Prompt libraries with clear intent and scope
- “Just ask the AI” with no stored prompt
- Prompt iteration without version history
- Copy‑pasted prompts from the internet
- Blind trust in model defaults
- No reproducibility
- No accountability
- Inability to explain why code exists
AI must consume explicit metadata, not infer system intent.
- Service definitions (API contracts, schemas, SLAs) provided as structured input
- AI prohibited from inventing requirements
- Metadata validated before generation
- Same metadata reused for docs, CI, and governance
- “Let the AI decide” architecture
- Implicit requirements hidden in conversation
- AI inferring data models from examples
- No schema validation before generation
- Services that do the wrong thing very well
- Inconsistent contracts across services
- Governance collapse
AI output must be reproducible or replayable.
- Prompt + metadata + model version recorded
- Generation wrapped in scripts or pipelines
- AI used to generate code once, then validated
- CI verifies regeneration consistency where possible
- Conversational, unlogged generation
- “Just regenerate until it looks right”
- Changing model versions silently
- Human fixes applied without updating prompts
- Non‑auditable systems
- Impossible rollback
- Loss of trust in AI output
AI‑generated code must never overwrite human intent.
- Clear separation between AI‑generated scaffolding and human logic
- AI restricted to specific directories or file types
- Humans remain final authors of business logic
- Explicit extension points for AI output
- Letting AI refactor core business logic
- “Fix this file” prompts on handcrafted code
- AI overwriting human decisions
- No review boundary between AI and human changes
- Loss of code ownership
- Silent semantic regressions
- Engineers become reviewers, not designers
AI output must meet production standards, not demo standards.
- Same linters, tests, and performance gates apply
- AI output treated as junior‑level code by default
- Mandatory human review for correctness and intent
- Explicit rejection of hallucinated abstractions
- “It compiles, ship it” mentality
- Excessive abstraction from generic AI patterns
- Over‑engineering due to prompt vagueness
- Security assumptions copied from training data
- Security vulnerabilities
- Performance regressions
- Maintenance nightmares
- AI makes architectural decisions without human review
- No ADRs or rationale
- Architecture becomes accidental
- Prompts evolve informally in chat
- Generated code no longer matches intent
- No single source of truth
- Patterns copied because the AI suggested them
- No understanding of tradeoffs
- Fragile systems
- Prompts are code
- Metadata defines truth
- AI proposes; humans decide
- Regeneration must be explainable
- If you can’t audit it, you can’t ship it
- “We don’t know which prompt generated this.”
- “The model changed, but nothing should break.”
- “The AI said this was best practice.”
- “We’ll clean it up later.”
AI‑assisted service generation is not unsafe —
undisciplined AI usage is.
When governed by the same principles as traditional generators, AI:
- accelerates scaffolding,
- improves consistency,
- and frees humans to focus on intent.
Without governance, AI:
- automates misunderstanding,
- hides responsibility,
- and scales architectural debt instantly.
AI does not remove responsibility, it concentrates it even more than generators.
The discipline you apply determines whether AI multiplies insight or error.