Engineering AI Coding Practices: Achieving 96% Cross-Project Code Consistency with onexai
The author details how they built the onexai toolkit — 46 convention tools and 20 scaffolding commands — to feed structured, high-quality Go standards to AI via MCP, enabling consistent, production-grade code across projects with 96% similarity to reference implementations like miniblog and onex.
AI Coding Experience: Strengths and Weaknesses
Over the past six months the author has used AI for daily coding, primarily with claude-sonnect-4-6 and deepseek-v4-pro, switching based on token usage and task complexity. AI now handles roughly 80% of development needs; after a light review the code ships to production. For solution design AI also proposes solid options, though some designs still require human input or multi-turn refinement.
The author envisions a future team of two senior engineers/architects plus one agent (e.g., Claude Code) and one junior engineer. The seniors own core architecture, feature design, and the AI constraint framework; the agent assists with feature implementation; the junior handles deployment, cloud resources, networking, and other ops tasks that AI cannot do — effectively acting as a safety net for AI.
Problems Encountered
Inconsistent development style across projects: Within a single project AI follows existing conventions, but across a team, department, or company each AI-coded project diverges in style, component reuse, package reuse, and error-code standards. Personal SKILL/MCP tool sets also lack standardization and are hard to distribute.
Excessive defensive code: AI generates many unnecessary defensive checks, bloating the codebase.
Repeated prompting of conventions: Every new feature or service requires re-feeding the same rules to AI. In a new service the prompt grows even larger. The author wants to avoid this repetition.
Borrowing Solutions from the Pre-AI Era
AI's current capability is essentially a junior-to-mid-level engineer with superb memory and coding speed but limited system-level design and complex-logic experience.
The author benchmarks AI against human engineers:
Simple projects/features: AI coding capability > senior engineer (efficiency, convention adherence, implementation choices, exception handling).
Complex projects: AI coding capability <= senior engineer. Context limits, attention span, and domain-depth gaps prevent AI from matching an experienced Go senior/expert in holistic design.
Therefore AI's coding ability is <= senior engineer; the main difference from a human junior is automation and speed. The quality issues AI faces — breaking architecture, ignoring edge cases, lacking global view, inconsistent style — mirror those of human juniors. The decades-old software-engineering toolkit for managing junior engineers (capability building, documented conventions, tooling, scaffolding, automated quality gates, code review, and deep product understanding) is the right medicine for AI coding.
In the AI era, conventions, scaffolding, design patterns, and methodologies become data . The core path to quality is feeding AI a complete set of high-quality data in an AI-friendly way.
onexai Harness AI Coding Toolkit
Leveraging a high-quality knowledge base built from course materials, the author created a standardized Go application development system covering methodology, design patterns, conventions, scaffolding, architecture foundation, and core Go packages. The system is still at best-practice level.
Characteristics of High-Quality Data for AI
Structured: AI understands structured data (e.g., JSON examples) far better than verbose prompts.
Consistent: Rules spanning multiple docs, tools, or repos must stay globally consistent to avoid confusing AI.
High-quality: Conventions, code, designs, and implementations must follow best practices.
Extensible: A plug-and-play, clearly defined extension mechanism lets AI iterate faster and better.
The author's approach: tool all high-quality data and feed it progressively to AI via MCP tools and SKILLs.
Convention Tooling
The complete convention system from the course was refined and packaged into 46 MCP tools . They cover the full Go cloud-native enterprise lifecycle: architecture, CLI/REST/gRPC/micro-frontend development, testing, observability, troubleshooting, and CI/CD.
Each convention is exposed as an MCP tool named convention_<subcommand> (hyphens preserved). The onexai convention overview command returns a categorized index with three rule levels:
Mandatory (强制): Must be followed; exceptions need formal approval. New projects enforced from design; existing projects improved incrementally.
Recommended (建议): Follow unless justified. New projects default on; existing projects adopt incrementally.
Reference (参考): Guidance only, not mandatory.
The overview groups conventions into Core Principles, Coding Standards, API & Error Handling, Architecture & Design, Operations, Platform & Development, AI & Methodology, Scaffold & Tooling, and Web Frontend. Example tools include convention_architecture, convention_coding, convention_error-return, convention_grpc, convention_rest-api, convention_ci, convention_prd, convention_scaffold, and convention_web-frontend.
To avoid context overload, conventions are fed progressively:
New projects: generate convention-compliant code from the start.
Periodic normalization: run onexai review (or /review) at defined stages to enforce conventions in bulk, specifying a rule level.
Ad-hoc: let AI decide which convention to fetch via onexai rag (semantic lookup).
All onexai tools automatically become MCP tools and connect to Claude Code and other AI IDEs.
Scaffolding for Framework Code
Conventions alone are documents; scaffolding enforces them. onexai create bundles 20 scaffolding commands that produce directory structure, architecture, implementation style, conventions, and package references with high — often total — consistency. The generated code becomes the best training data for subsequent AI iterations.
Available commands:
quickstart Create demo/learning project (NOT for production)
project Create new project from YAML (needs onexstack.yaml)
webserver Create REST API / Web service (main command for web apps & APIs)
api Create API resource
jobserver Create async task / Cron consumer service
job Add async handler for existing JobServer
mqserver Create Kafka consumer project
mq Create MQ consumer
mcpserver Create MCP tool service project
mcp Create new MCP tool
clitool Create CLI tool project
cmd Create new CLI command
console Create modern web frontend project
micro Create micro-frontend child app for existing console
declserver Create declarative (kube-apiserver style) API service
crd Add REST resource (CRD) to declserver
controller-manager Create controller aggregation (kube-controller-manager style)
controller Add controller watching CRD to controller-manager
operator Create standalone controller-runtime operator
operator-api Add CRD + controller to operatorReal-World Results
Daily development uses onexai create to generate the codebase, then AI coding on top. A company-internal Helper AIOps platform — 33,292 lines spanning Web Server, MCP Server, and Job Server — was entirely scaffolded with onexai create and has shown no extensibility issues.
Over a weekend the author refactored two 100k+ line projects (frontend to backend) using onexai's approach. A single prompt per project sufficed; the refactored code aligned highly with the OneX tech stack's style, architecture, and patterns. Total token cost: ~¥100+. With stricter convention enforcement, quality rises another 20%+.
Motivation and Vision
The core goal: solidify Go best practices via engineering, distribute them through MCP tools, and unify architecture, style, conventions, shared packages, design patterns, and methodology across the company — pushing AI coding further. One-click distribution enables minimal-cost, maximum-quality development. If the author starts a company, this toolkit would bootstrap the entire tech stack rapidly.
Future development model:
Describe requirements in natural language → convert to Stories (PRD).
Run onexai prd translate -i prompt.md -o prd.md to generate structured Stories with acceptance criteria.
Execute
onexai prd run --all-levels --tui --review-timing=at-end prd.mdto implement all Stories, then run a full-convention review at the end (saves tokens; --review-timing=per-story runs review after each Story).
The author demonstrated building a ticket-management system (auth, ticket CRUD, comment CRUD, timeout-closure cron job, admin CLI) from a one-line prompt. The resulting onex-harness-demo repo was compared by AI against two reference codebases: miniblog:
https://github.com/onexstack/miniblog onex: https://github.com/onexstack/onex AI-rated similarity across architecture, logging, directory structure, conventions, implementation style, error handling, and shared packages reached 96/100 . Since miniblog is known for very high code quality, onexai-produced projects inherit both consistency and quality.
Legacy low-quality projects can be one-click refactored (frontend + backend) with prompts like:
请阅读cmd/ks-controller-manager代码,使用onexai create controller-manager/controller 命令,重构ks-controller-manager的实现。
在重构时,先使用onexai create controller-manager/controller 实现完整的框架代码,然后再迁移ks-controller-manager的所有逻辑,然后再编译,测试通过。
在迁移时,要注意不要遗漏ks-controller-manager 的任何逻辑。并且配置、资源等,要跟cmd/ks-controller-manager 保持一致。这样做的核心目的时,迁移后的代码,能够完成跟cmd/ks-controller-manager 一样的功能、配置等也能适配。
在迁移的过程中,请遵循 OneX 技术栈的规范。Or simply:
请使用 OneX 技术栈重构本项目。Future Roadmap
The author plans to build the full OneX platform — a course cloud similar to a public cloud — offering AI Infra learning paths and hands-on projects. Users will request AK/SK and connect via Remote MCP Server to Claude Code, instantly reusing OneX Harness AI Coding's full-stack capabilities and applying what they learn directly to their own apps.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Go Programming World
Mobile version of tech blog https://jianghushinian.cn/, covering Golang, Docker, Kubernetes and beyond.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
