[D] Generation AI Services - RobertArtigas/DCT2CLASS_Docs GitHub Wiki
Code Generation Principles Mapped to AI‑Assisted Service Generation
Applying Non‑Negotiable Principles When Using AI to Generate Services
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 Context: Why This Is Different
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.
Principle 1: Full Ownership and Control of Generation Templates (Prompts)
AI Interpretation
Prompts are templates. You must own and control them.
Good Practices
- 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
AI‑Specific Anti‑Patterns
- “Just ask the AI” with no stored prompt
- Prompt iteration without version history
- Copy‑pasted prompts from the internet
- Blind trust in model defaults
Failure Mode at Scale
- No reproducibility
- No accountability
- Inability to explain why code exists
Principle 2: Metadata Is a First‑Class, Independent Artifact
AI Interpretation
AI must consume explicit metadata, not infer system intent.
Good Practices
- 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
AI‑Specific Anti‑Patterns
- “Let the AI decide” architecture
- Implicit requirements hidden in conversation
- AI inferring data models from examples
- No schema validation before generation
Failure Mode at Scale
- Services that do the wrong thing very well
- Inconsistent contracts across services
- Governance collapse
Principle 3: Deterministic, One‑Click Regeneration
AI Interpretation
AI output must be reproducible or replayable.
Good Practices
- 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
AI‑Specific Anti‑Patterns
- Conversational, unlogged generation
- “Just regenerate until it looks right”
- Changing model versions silently
- Human fixes applied without updating prompts
Failure Mode at Scale
- Non‑auditable systems
- Impossible rollback
- Loss of trust in AI output
Principle 4: Handcrafted Code Is Protected and Respected
AI Interpretation
AI‑generated code must never overwrite human intent.
Good Practices
- 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
AI‑Specific Anti‑Patterns
- 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
Failure Mode at Scale
- Loss of code ownership
- Silent semantic regressions
- Engineers become reviewers, not designers
Principle 5: Generated Code Must Meet or Exceed Handwritten Quality
AI Interpretation
AI output must meet production standards, not demo standards.
Good Practices
- 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
AI‑Specific Anti‑Patterns
- “It compiles, ship it” mentality
- Excessive abstraction from generic AI patterns
- Over‑engineering due to prompt vagueness
- Security assumptions copied from training data
Failure Mode at Scale
- Security vulnerabilities
- Performance regressions
- Maintenance nightmares
Cross‑Cutting AI Anti‑Patterns
“AI as Architect”
- AI makes architectural decisions without human review
- No ADRs or rationale
- Architecture becomes accidental
“Prompt Drift”
- Prompts evolve informally in chat
- Generated code no longer matches intent
- No single source of truth
“AI Cargo Cult”
- Patterns copied because the AI suggested them
- No understanding of tradeoffs
- Fragile systems
High‑Leverage AI Guardrails
- 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
AI‑Specific Red Flags
- “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.”
Summary
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.
Closing Insight
AI does not remove responsibility, it concentrates it even more than generators.
The discipline you apply determines whether AI multiplies insight or error.