AI Programming in Practice: From Environment Setup to Multi-Agent Collaboration
This article explains how to use AI coding assistants as part of a repeatable engineering workflow rather than as a shortcut for generating code. It covers the right mental model, minimal environment setup, a small first project, a plan-execute-verify-retrospective loop, project context and conversation design, advanced skills, hooks, context protocols, multi-agent collaboration, and common pitfalls. Readers will learn how to organize goals, constraints, context, permissions, and acceptance criteria so that AI-assisted development becomes more predictable and easier to validate.
AI coding tools are moving from “code completion” toward “engineering collaboration.” What really determines output is no longer whether a single generation looks impressive, but whether developers can organize goals, constraints, context, permissions, and acceptance criteria into a repeatable workflow. This article uses general engineering practice as its thread to discuss how to use intelligent coding assistants for a systematic upgrade—from environment setup and a first project to multi-agent collaboration.
1. Start with the Right Mental Model: AI Is Not a Ghostwriter
Many people first treat an AI coding assistant as a faster search engine or a code ghostwriter: enter a requirement and expect runnable results directly. In the short term this can solve small problems, but over time it often leads to rework. The reason is that software development is not about isolated code snippets; it is a closed loop of requirement clarification, architecture tradeoffs, dependency management, test verification, deployment and rollback, and documentation.
A more reasonable mental model is this: AI handles rapid exploration, draft generation, repetitive work, and document organization, while humans handle goal definition, boundary constraints, key decisions, and final acceptance. Developers should treat AI as a “fast collaborator that needs guardrails,” not as an “automatic machine that needs no review.” Therefore, when using an AI coding assistant, three things should be established first: a clear task description, verifiable acceptance criteria, and the minimum necessary permission boundary.
Tasks suitable for AI usually include boilerplate code generation, interface drafts, test case completion, log analysis, refactoring suggestions, documentation drafts, and configuration checks. Tasks that should not be fully delegated include operations involving sensitive data, deployment changes that cannot be rolled back, complex business rule tradeoffs, and security boundary design. The clearer the division of labor between humans and AI, the more stable the efficiency gains will be.
2. Environment Setup and the First Project: Get the Smallest Closed Loop Working
The goal of environment setup is not to “finish installing tools,” but to establish an inspectable, minimally usable environment. When choosing an interaction mode, decide based on the task: terminal-based interaction suits scripts and automation, in-editor inline assistance suits local edits, web chat suits solution discussion, and voice interaction suits quickly recording ideas. Regardless of the mode, check versions, network, dependencies, keys, logs, and rollback capability.
For the first project, choose a low-risk, verifiable task. For example, a personal homepage: first define the page structure and content, then implement responsive layout, accessibility checks, and static deployment. Acceptance criteria can be “no horizontal scrolling on mobile, key information complete, and build without errors.” A second small project can be an information aggregator: define data sources, scraping, cleaning, deduplication, sorting, caching, and scheduling. Acceptance criteria include “duplicate data can be removed, failures can be retried, and logs can be traced.” Such projects are small in scale but cover the full loop of requirements, implementation, verification, and deployment.
The key mindset is “commit in small steps, get it working first, then optimize.” Do not propose a huge requirement all at once. Instead, break the task into reviewable changes: build the skeleton first, then add features, then add tests, and finally write documentation. At each step, require AI to state assumptions, list risks, and provide a verification method.
3. Core Workflow: Plan, Execute, Verify, Retrospective
A high-quality AI programming workflow can be summarized in four steps.
First, plan. Discuss before executing, and clarify goals, non-goals, constraints, dependencies, and acceptance criteria. Ask AI to output a task breakdown and risk list first, rather than directly changing code. The planning phase should answer: which files will be changed? Which files must not be touched? How will it be verified? How will failure be rolled back?
Second, execute. The execution phase needs permission tiers: read-only, writable, ask before action, and forbidden. Set write access to forbidden for sensitive directories, deployment configurations, and key files; set network access, dependency installation, and deployment operations to ask; set normal source code modifications to a whitelist. Least privilege is not about distrusting AI; it is about reducing the cost of mistakes.
Third, verify. Every change should go through tests, static checks, builds, regression, and log observation. AI can generate test cases, but humans must confirm whether the tests cover real risks. Verification criteria should be defined upfront; do not stop simply because it “looks like it runs” afterward.
Fourth, retrospective. Capture failure causes, effective prompts, architecture decisions, and troubleshooting processes in project documentation. Session context will grow, but project knowledge must not be lost. Use summaries, archives, and task-level session management to avoid turning historical conversations into a “junk pile.”
Version control is the safety net for this workflow. Commit in small steps, write clear change notes, branch when necessary, and roll back quickly when something goes wrong. After AI generates changes, review the diff—especially dependency changes, permission changes, and data processing logic.
4. Project Context Configuration and Conversation Strategy
AI output quality depends heavily on context quality. Project-level context configuration should include project goals, architecture overview, directory conventions, coding standards, testing and checking methods, prohibited actions, a glossary, and acceptance criteria. Configuration is not better when longer; it should be stable, maintainable, and executable.
project:goal: "Build an information aggregator"context_files:- docs/architecture.md- docs/conventions.mdconstraints:- "Do not write to sensitive directories"- "Validate all external input"validation:- "Run unit tests"- "Run static checks"- "Generate change notes"permissions:read: ["src/**", "docs/**"]write: ["src/**", "tests/**"]ask: ["Network access", "Dependency installation", "Deployment configuration changes"]
Conversation strategy is equally important. An effective template is: goals, non-goals, constraints, input, output format, and acceptance criteria. Ask AI to list assumptions and risks first, then provide a step-by-step plan; ask it to explain key tradeoffs; ask it to self-check whether the acceptance criteria are met. Avoid pasting large amounts of irrelevant logs at once, and avoid unverifiable instructions such as “help me optimize this.” Break large tasks into phases, each with a clear artifact.
5. Advanced Capabilities: Skills, Hooks, Context Protocols, and Multi-Agent Collaboration
Once the basic workflow is stable, advanced capabilities can be introduced. Reusable skills encapsulate repeated processes as instructions, scripts, or checklists—for example, a “new page checklist” or a “pre-release security review checklist”—and should be version-controlled. Event hooks automatically trigger checks at key points, such as running static checks before commit, generating change notes after a build, or running a security scan before deployment. Context protocols connect external knowledge and tools in a standard way, with emphasis on permissions, auditing, and traceability.
Multi-agent collaboration suits the decomposition of complex tasks: a planner breaks down work, an implementer writes code, a reviewer finds defects, and a tester verifies results. But more agents are not always better. Stop conditions, handoff formats, and arbitration rules must be defined; otherwise, the process can fall into endless discussion. Deployment and observability can be supported by general product categories such as object storage, log services, monitoring and alerting, and container platforms from Baidu AI Cloud, but the core remains the engineering process rather than an accumulation of tools.
6. Three Cases in General Terms
The personal homepage case focuses on concise requirements, clear structure, accessibility, and rollback-capable deployment. The information aggregator case focuses on the data pipeline, deduplication, caching, scheduling, failure retry, and log observability. The internal tool or small product case focuses on permissions, auditing, configuration management, release process, and documentation. Together, the three cases show that AI can accelerate implementation, but productization depends on acceptance criteria and engineering guardrails.
7. Common Pitfalls and Conclusion
Common pitfalls include treating AI as a search engine, ignoring context, lacking acceptance criteria, granting excessive permissions, not reviewing changes, letting context grow without limit, and overbelieving in multi-agent collaboration. A more robust mental model is: AI is a fast intern, the engineering process is the guardrail, acceptance criteria are the contract, and project context is the requirements document. By continuously measuring delivery cycle, rework rate, defect rate, and review time, and by regularly reviewing prompts and configuration, teams can turn AI programming from “occasionally useful” into “stable and dependable” productivity.
