—— How OpenAI Built a Million-Line Codebase with Codex
Recently, the OpenAI engineering team shared an article that is well worth reading for engineers:
Original article: https://openai.com/zh-Hans-CN/index/harness-engineering/
The article describes an experiment they ran:
Build a real software product where not a single line of code in the entire codebase is written by a human.
All the code, including:
- application logic
- tests
- CI/CD
- documentation
- operational scripts
- internal tools
was generated entirely by Codex.
And the human engineers did only one thing:
Design systems, constraints, and feedback loops.
In the end, they used 3 engineers to build a system approaching 1 million lines of code in 5 months.
The article actually reveals an important trend:
Software engineering is shifting from “writing code” to “designing systems that AI can work in.”
Below, I break down the core content of the article and analyze what it means for future engineering models.
1. The experiment: a product whose code was generated entirely by AI
The OpenAI team started from an empty Git repository.
The initial architecture was generated automatically by Codex + GPT-5, including:
- project structure
- CI configuration
- code formatting rules
- package management
- application framework
- AGENTS.md
Even:
The documentation that tells AI how to work in the repository was also written by AI.
Five months later, the result was:
- about 1 million lines of code
- 1,500+ pull requests
- a team of only 3 engineers
- an average of 3.5 PRs per person per day
The system already had:
- internal daily active users
- external Alpha users
In other words:
This was not a demo. It was a real, running product.
Their core principle was:
Humans steer, agents execute.
2. The engineer’s role changed
Under this system:
Engineers barely write code.
Their job became:
1️⃣ design the system structure 2️⃣ define task goals 3️⃣ design feedback loops 4️⃣ build tools that AI can use
In other words:
Before:
Engineer -> writes code -> opens PR
Now:
Engineer -> describes task
-> runs Agent
-> Agent opens PR
-> Agent review
-> automatic fixes
The whole process looks something like this:
Engineer
↓
Prompt
↓
Codex
↓
Open PR
↓
Agent Review
↓
Fix
↓
Merge
In many cases:
Even PR review is done by AI.
3. The system must be “agent-readable”
A very important lesson:
Knowledge the agent cannot see = knowledge that does not exist.
For example:
- Slack discussions
- Google Docs
- human memory
are all invisible knowledge to AI.
So they made a key decision:
Make the code repository the single source of truth.
Everything went into the repo:
- architecture docs
- design docs
- product specs
- execution plans
- technical debt
- decision records
The directory structure looked roughly like this:
AGENTS.md
ARCHITECTURE.md
docs/
├ design-docs/
├ exec-plans/
├ product-specs/
├ references/
├ SECURITY.md
├ RELIABILITY.md
└ QUALITY_SCORE.md
AI used this structure to:
- find information
- reason about the system
- modify code
They called this approach:
Agent-readable repository
4. Don’t write a 1,000-line prompt
They once tried:
one huge AGENTS.md
It failed completely.
The reasons:
1. Context windows are a scarce resource
Long documents crowd out:
- code
- tasks
- important context
2. Too many rules stop working
When everything matters:
nothing matters.
3. Documentation rots
If maintenance costs are too high:
documentation becomes:
a graveyard of expired rules
The approach they eventually adopted was:
AGENTS.md as a table of contents only
Something like:
AGENTS.md
↓
ARCHITECTURE.md
↓
docs/
↓
design-docs/
That is:
Give AI a map, not a manual.
5. Architecture must be strict
In this environment, agents have a characteristic:
They copy existing patterns.
If the architecture is not strict:
code drifts quickly.
So they enforced:
a strictly layered architecture
For example:
Types
↓
Config
↓
Repo
↓
Service
↓
Runtime
↓
UI
Rules:
- dependencies may only point downward
- cross-layer calls are not allowed
All rules were enforced automatically through:
- custom linter
- structural tests
In other words:
Architectural constraints are enforced by machines.
6. Throughput changed engineering culture
Agents write code far faster than humans.
This created a new problem:
Code throughput far exceeds human review capacity.
So they changed traditional engineering culture:
Before:
strict gate
review required
CI must pass
Now:
merge fast
fix problems later
Because:
The cost of waiting is higher than the cost of fixing.
7. AI can complete the entire development workflow automatically
As the tools matured, Codex could now:
automatically complete the entire development workflow:
1️⃣ verify the state of the codebase 2️⃣ reproduce the bug 3️⃣ record a video of the bug 4️⃣ implement the fix 5️⃣ run the app to verify 6️⃣ record a video of the fix 7️⃣ open a PR 8️⃣ handle review 9️⃣ fix CI 🔟 merge automatically
Humans step in only when necessary.
8. A new problem: AI creates “technical debt”
Fully AI-driven development brings a problem:
AI copies bad patterns.
For example:
- inconsistent implementations
- unreasonable abstractions
- duplicate tools
Their initial approach was:
clean up AI code every Friday.
Later they found this didn’t scale.
The eventual solution was:
Encode engineering principles in code.
For example:
- ban YOLO parsing
- require typed SDKs
- prefer shared tool libraries
Then:
run a Refactor Agent regularly.
Something like:
automatic garbage collection (GC).
9. The truly scarce resource: human attention
The article ends with this summary:
The bottleneck in software engineering is no longer writing code. It is human attention.
The core questions for future engineering systems become:
- how to design the environment
- how to design feedback loops
- how to design constraint systems
rather than:
writing code.
10. What this means for the future of software engineering
The article reveals a very important trend:
Software engineering is entering:
Agent-first engineering
Future engineers will look more like:
system designers
and less like:
code workers
The core skills of the future may be:
- architecture design
- Agent workflow
- engineering automation
- feedback loop design
- engineering knowledge modeling
rather than:
- writing CRUD
Conclusion
This article really shows one thing:
AI is not just a code-writing tool.
It is changing:
the structure of software engineering itself.
Future software teams may become:
a small number of engineers
+
a large number of AI Agents
+
a highly structured code repository
And the core value of engineers will become:
designing systems in which AI can work efficiently.