AI Coding Tools: Role Separation and an Architecture-First Workflow

    AI coding tools deliver the most value when they operate within a clear software development process. This article distinguishes exploratory problem solving from deterministic implementation, presents a four-stage workflow, and uses an information-propagation system in a historical simulator to show why domain modeling, explicit relationships, event flows, and invariants should come before code generation. It also provides practical safeguards for testing, review, and incremental delivery.

    AI Coding Tools: Role Separation and an Architecture-First Workflow

    As AI coding tools become increasingly common, the question of which tool to choose can distract from a more important issue: where each tool belongs in the software development lifecycle.

    AI coding tools cannot replace requirements analysis, domain modeling, or architecture design. They are more effective at expanding ideas, filling in implementation details, generating tests, and accelerating refactoring when clear constraints already exist. Treating an AI coding tool as an entry point for building an entire system from scratch may appear fast at first, but it often creates tightly coupled code and expensive rework over time.

    A more reliable approach is to use a conversational coding assistant early to broaden perspectives and identify omissions, have developers lead abstraction and architecture work in the middle, and use code generation later to fill in constrained implementation details. The following sections examine this approach through activity classification, workflow design, domain modeling, and risk control.

    1. Distinguish Exploratory Reasoning from Deterministic Implementation

    The effectiveness of an AI coding tool depends largely on whether the current task is still in an exploratory phase or has entered a convergent implementation phase.

    1.1 Exploration: Use Tools to Expand the Solution Space

    During exploration, the problem itself may not yet be fully understood. Terminology may be inconsistent, system boundaries may be unclear, or interaction flows may still be under discussion.

    At this stage, the tool is most useful for offering multiple perspectives, such as:

    • Possible data structures
    • Common state models
    • Easily overlooked exception paths
    • Alternative interaction patterns

    The goal should not be to obtain final code immediately. Instead, treat the tool as a participant in a technical discussion: ask questions, compare alternatives, and identify gaps.

    The outputs of the exploration phase should be a domain glossary, a list of open questions, candidate solutions, and the rationale behind key trade-offs, rather than a large block of unreviewed code.

    1.2 Convergence: Use Tools for Constrained Implementation

    Once the entities, relationships, event flows, state machines, interface boundaries, and invariants have been clarified, the tool can move into a filling-in role.

    It can help generate:

    • Data classes
    • Transformation functions
    • Validation logic
    • Unit tests
    • Documentation comments
    • Refactoring suggestions

    The tool must receive sufficiently precise constraints, including input and output definitions, exception conditions, idempotency requirements, transaction boundaries, and naming conventions.

    The outputs of this phase should be small, reviewable, testable, and reversible changes, not a large set of interdependent modules generated in one pass.

    1.3 The Biggest Risk: Generating Code Before Defining the Framework

    If the domain model is not yet understood, asking a tool to “start coding” usually leads to generic but shallow decisions:

    • Store every concept as a field
    • Flatten relationships wherever possible
    • Represent states with Boolean values

    As more features are added, these local decisions become global coupling. The faster the code is generated, the faster mistakes spread.

    Therefore, code generation should follow abstraction, not replace it.

    2.1 Problem Abstraction: Define Entities, Relationships, Events, and Invariants

    Before implementation begins, answer several fundamental questions:

    • What are the core entities in the system?
    • What asymmetric relationships exist between entities?
    • Which events can change state?
    • Which constraints must always remain valid?

    The output at this point should not be code. It should be a domain-model sketch, a glossary of terms, and clear boundary definitions.

    2.2 Architectural Skeleton: Let Developers Lead Module and Data-Flow Design

    The architectural skeleton should define:

    • Module responsibilities
    • Data flow
    • Interface contracts
    • Consistency strategies
    • Error-handling strategies

    Automatic decision-making by tools should be minimized at this stage. Tools can be used to compare alternatives, but the final trade-offs must be expressed as explicit constraints and approved by developers.

    2.3 Detailed Implementation: Generate and Validate in Small Steps

    Once implementation begins, generate code one interface or module at a time and create unit tests alongside it.

    After each small module is completed:

    • Run the tests
    • Check for unnecessary coupling
    • Update the documentation
    • Review the change before moving forward

    This prevents a large amount of uncontrolled code from entering the system at once.

    2.4 Verification and Evolution: Use Tests and Reviews to Constrain Generated Code

    Generated code must pass static checks, unit tests, integration tests, and code review.

    Tests are not only a way to verify the implementation. They also act as a specification that constrains tool output. Critical paths should receive additional regression coverage so that later refactoring does not change established behavior unexpectedly.

    3. Example: Modeling Information Propagation in a Historical Simulator

    Consider a historical simulator whose core mechanism is the spread and transformation of information among people.

    Characters retell stories through their own perspectives. Narrators record or recount rumors, and later generations form new interpretations from those records. Although this may appear to be a narrative problem, it is fundamentally a domain-modeling problem.

    3.1 Domain Abstraction: People, Relationships, Rumors, Memories, and Narratives

    The following core objects can serve as a starting point:

    • People and groups: Have positions, knowledge boundaries, trust tendencies, and interests.
    • Relationships: Include closeness, trust, power, interests, and suspicion. These relationships are usually asymmetric.
    • Rumors and events: Include an original proposition, source, time, channel, and confidence level.
    • Memories: Represent a character’s cognitive state regarding a proposition, such as believed, doubted, rejected, or unknown.
    • Narrative works: Textual or oral records created through retelling, selection, and interpretation.
    • Investigation state: Represents a verification process triggered when suspicion reaches a threshold.

    Important invariants should be explicit:

    • Every memory must record its source.
    • Every retelling must pass through a cognitive filter.
    • Changes in relationships can affect confidence.
    • Investigation results must update the corresponding cognitive state.

    3.2 Information Flow: Observation, Memory, Retelling, Recording, and Reinterpretation

    Information should not be copied directly from one character to another. It should pass through a sequence of state transformations.

    First, an observer forms a memory. That memory is influenced by existing beliefs and relationships. When the information is retold, it passes through a narrative filter that may strengthen, weaken, or distort it. A recorder then creates a narrative work based on their own understanding. When later generations read the work, they form another interpretation.

    Each step should preserve the source and confidence level. Without this traceability, the system cannot explain how a later belief was formed.

    3.3 How Relationships Affect Cognition: An Example of Romantic Evaluation

    Consider a character evaluating a potential partner.

    The protagonist’s opinion may be influenced by parents, siblings, friends, and other people. Those opinions may themselves depend on how each person evaluates the subject’s occupation, family background, and relationship with the protagonist.

    Representing all of this with a single likability field quickly loses important structure. A more suitable model should represent:

    • Multiple viewpoints
    • Viewpoint weights
    • Relationship closeness
    • Conflicts of interest

    Aggregation rules can then be used to derive the protagonist’s cognitive state.

    3.4 Illustrative Pseudocode

    1. Entity:
    2. id
    3. kind
    4. attributes
    5. Relation:
    6. source_id
    7. target_id
    8. relation_type # closeness, trust, power, interest
    9. weight
    10. asymmetric
    11. Memory:
    12. holder_id
    13. subject_id
    14. proposition
    15. source_id
    16. confidence
    17. suspicion_level
    18. timestamp
    19. PropagationEvent:
    20. rumor_id
    21. from_id
    22. to_id
    23. channel
    24. content_transform
    25. timestamp
    26. function propagate(event, relation, memory):
    27. transformed = apply_narrative_filter(event.content, relation, memory)
    28. confidence = estimate_confidence(event, relation, memory)
    29. update_memory(event.to_id, transformed, confidence)
    30. if confidence < threshold and relation.trust < trust_threshold:
    31. trigger_investigation(event.to_id, event.rumor_id)

    This structure separates information abstraction from information flow:

    • Entities and relationships define the domain structure.
    • Events and state machines define the propagation process.
    • Cognitive filters define subjective transformation.

    Only after these frameworks are established can a code generation tool safely fill in validation, aggregation, query, and testing logic.

    4. Why Tools Should Not Build the System from Scratch

    There are several reasons to avoid having an AI coding tool construct an entire system without a clear model.

    First, the tool lacks long-term business objectives and may choose a general-purpose but shallow model.

    Second, it does not automatically understand real-world conflicts of interest or narrative constraints. It may not independently identify domain details such as “suspicion triggers an investigation” or “relationships affect credibility.”

    Third, local generation decisions do not necessarily produce a coherent global structure. A large number of individually reasonable choices can accumulate into significant coupling.

    Fourth, generation speed can amplify mistakes. Without testing and review, the resulting rework may cost more than the time saved through automation.

    5. Practical Checklist

    1. Write the domain glossary and boundary definitions before asking the tool to generate code.
    2. Define interface contracts and invariants before generating implementations.
    3. Use explicit structures for important relationships instead of compressing complex semantics into Boolean fields.
    4. Require tests and review for every generated module.
    5. Commit and validate in small increments; do not stack large amounts of generated code in one pass.
    6. Record architecture decisions, and require future generated code to follow those constraints.

    Conclusion

    The true value of AI coding tools is not replacing developer reasoning. It is amplifying implementation efficiency within a clear framework.

    Use conversational assistants to broaden perspectives during exploration, and use code generation tools to fill in constrained details after the design has converged. Domain abstraction, relationship modeling, event flows, and invariants must remain developer-led.

    Abstract first, implement second, and use tests to constrain generated results. This approach improves development speed while reducing the risk of accumulating an unmaintainable codebase.