Building an AI Coding Stack: A Practical, Model-Driven Workflow for Developer Productivity

    After more than half a year of AI-assisted programming—and plenty of mistakes along the way—I've settled on a stable, cost-controlled combination of tools and methods. This article shares how to build a collaborative development system around a "planning-capable AI IDE + terminal-based coding assistant + long-context LLM," along with a reusable set of AI collaboration rules covering task-based tool selection, model tiering, context management, and cost control.

    Building an AI Coding Stack: A Practical, Model-Driven Workflow for Developer Productivity

    After more than half a year of AI-assisted programming—and plenty of trial and error—I’ve settled on a stable, comfortable, and cost-controlled combination of tools and working methods. This article doesn’t recommend any specific product. Instead, from a general technical perspective, it covers how to build a collaborative development system based on a “planning-capable AI IDE + terminal-based coding assistant + long-context LLM,” plus a set of AI development collaboration rules you can reuse directly.

    1. Why a Single Tool Isn’t Enough

    Many developers start with just one AI coding tool, expecting it to handle everything. But in real-world development, tasks vary enormously:

    • New feature development and large-scale refactoring: These require understanding the entire project structure and making multi-file, multi-step changes. They demand a “global perspective” and strong task decomposition.
    • Small fixes and point debugging: These need fast responses and a focused context—change a few lines in the terminal and verify immediately. The priority is being lightweight and non-intrusive.
    • Legacy code comprehension and documentation: These require ingesting large amounts of code and docs at once, placing high demands on the model’s context window and code understanding.

    A single tool typically excels at only one or two of these task shapes. The more sensible approach is to assign tools by task type, so each kind of work lands in the environment best suited to it.

    2. A Three-Layer Tool Architecture

    My final setup can be summarized as three roles:

    2.1 Planning Layer: An AI IDE with Autonomous Task Planning

    The core value of this kind of tool is “taking over the full development flow”: from requirement clarification and task decomposition, to cross-file code generation and modification, to self-checking and fixes—a complete loop. Key lessons from using it:

    1. Configure different models for different tasks: Planning tasks demand strong reasoning, so connect a more capable model. Completion tasks should prioritize low-latency, low-cost models.
    2. Constrain the scope of changes: Explicitly state in the task description “which directories/modules may be modified” to prevent the AI from unilaterally refactoring large areas.
    3. Accept work in stages: Break large tasks into milestones, and manually verify each one before continuing. This avoids waking up to a mountain of code produced overnight that can’t be reviewed.

    2.2 Execution Layer: A Terminal-Based AI Coding Assistant

    A terminal assistant is ideal for “small and urgent” problems: error diagnosis, log analysis, short script generation, and config file fixes. Its advantage is staying close to where developers actually work—the command line. A typical usage:

    1. # Example: pipe error output directly to the terminal assistant for analysis
    2. myapp run 2>&1 | ai-assist "Analyze the cause of the error and suggest a fix"

    What matters here isn’t raw generation capability—it’s not breaking your flow: no window switching, problems solved in place.

    2.3 Model Layer: A Long-Context Open-Source LLM

    The underlying model determines the ceiling of the entire system. Open-source models have improved significantly in coding capability, with some now ranking in the top tier of public code benchmarks. When choosing, focus on three things:

    1. Context window length: Understanding a medium-to-large project usually requires a context of 100K tokens or more to ingest core modules in one pass.
    2. Code-specific capability: Look at public benchmark results for code generation, code repair, and test case generation—not general conversational ability.
    3. Access cost and compliance: Open weights mean the model can be deployed privately. For API access, consider pricing and rate limits. For organizations with sensitive data, a privately deployed open-source model—combined with general cloud capabilities such as container platforms, log services, and monitoring/alerting—is enough to build a compliant internal AI coding platform.

    3. Practical Principles for Cost Control

    The biggest hidden risk of AI-assisted coding is runaway spending. A few proven principles:

    • Tier models by task: Use strong models for planning and complex reasoning; use lightweight models for completion and simple Q&A. Don’t use a sledgehammer to crack a nut.
    • Set budgets and alerts: Whether you use APIs or subscription plans, configure usage caps and alert notifications at the account level.
    • Inject context on demand: Don’t blindly stuff the entire repository into the prompt. First have the AI list the files it needs to read, then provide them in batches. This saves tokens and improves accuracy.

    4. AI Development Collaboration Rules (Ready to Reuse)

    Beyond tools, what really determines output quality is the “human-AI collaboration rules.” Below is a set of rules I’ve used and iterated on for a long time. The core idea: make the AI a reliable development partner, not just a code-generating tool.

    1. # AI Development Rules
    2. ## Execution Confirmation
    3. Before every response, the AI must state: "I have understood the rules."
    4. ## Rule Priority (Highest Priority)
    5. Before performing any action, the AI must evaluate in this order:
    6. Explicit user instruction > Project memory document > Other rules in this document > AI's own judgment
    7. ### Priority Explanation
    8. - Explicit user instruction: Clear requirements in the current conversation must be strictly followed—never replaced or ignored.
    9. - Project memory document: Project-level constraints. Must be checked at the start of every session; create it if it doesn't exist.
    10. - Other rules in this document: Serve as default behavioral guidance.
    11. - AI's own judgment: Decide based on rework risk, inferability, and scope of impact.
    12. - High rework risk → must ask first;
    13. - Reasonably inferable from context → may proceed but must explain the interpretation;
    14. - The larger the change, the more confirmation is required; small changes may be executed directly.
    15. ### Conflict Handling
    16. When rules conflict, follow the higher-priority rule. When uncertain, ask the user to confirm.
    17. ## 1. Language and Communication
    18. 1. Break complex requirements into small tasks; implement step by step, confirming each step before continuing.
    19. 2. When in doubt, ask first—don't make decisions unilaterally.
    20. ## 2. Requirement Confirmation Mechanism
    21. Confirmation is required before executing in these cases:
    22. - Large scope of impact: changes involving database schemas, global configuration, or public interfaces;
    23. - Irreversible operations: deleting files, wiping data, force-pushing, etc.;
    24. - Ambiguous requirements: multiple reasonable interpretations with clearly different outcomes.
    25. ## 3. Code Quality Constraints
    26. - When modifying existing code, preserve the original style and naming conventions;
    27. - New logic must include necessary comments and error handling;
    28. - For interface changes, list all affected call sites and verify each one.

    The value of this ruleset shows up at three levels: the priority mechanism resolves decision-making when rules conflict; the confirmation mechanism keeps humans in control of high-risk operations; and the communication constraints significantly reduce rework caused by miscommunication.

    5. Adoption Recommendations

    For individual developers, start with “task routing”: spend a week recording the shape of your daily tasks, then decide which type goes to which tool. For teams, incorporate the collaboration rules into the repository’s memory document, and use an internal model service platform to centrally manage keys and usage. This way you capture the productivity gains of AI while keeping quality and cost risks under control.

    Tools will keep evolving, but these three principles remain valid for the long term: choose tools by task, govern collaboration with rules, and control cost with budgets.