How to Make Claude Generate Good Code from the Start! Creating Project Rules with PROJECT.md
How to Make Claude Generate Good Code from the Start! Creating Project Rules with PROJECT.md
As you work on modifying AI-generated code, one truth becomes clear:
"It would have been better if it was built this way from the beginning."
In fact, many developers spend significant time refactoring.
However, in Vibecoding, we recommend a different approach:
Teaching AI the project’s rules from the start.
This lesson will show you how to use PROJECT.md to guide Claude to maintain consistent structure and style throughout your project right from the beginning.
Why Are Project Rules Necessary?
Without knowing a project’s development rules, AI generates code based on generic examples.
For instance:
Writing all code in controllers
Not using services
Using variable names that don’t match the project
Failing to create common functions
These issues can usually be resolved by defining rules upfront.
PROJECT.md Is AI’s Development Guide
Many people think of PROJECT.md as just a project introduction document.
But in Vibecoding, it’s the most important document.
Claude uses PROJECT.md to understand the project and applies the same rules when generating subsequent code.
In other words,
think of PROJECT.md not as documentation for developers but as a development guide for AI.
Must-Includes in Your Development Rules
We recommend defining the following in your PROJECT.md:
Item | Rule |
|---|---|
Framework | Express |
View Engine | EJS |
Database | MySQL (mysql2) |
Module | CommonJS |
CSS | Bootstrap |
Async | Use async/await |
SQL | Use Prepared Statements |
Config | Use dotenv |
With these rules, Claude will consistently develop the project using the same standards.
Clearly Define Your Folder Structure
It’s also helpful to define your project’s folder structure upfront.
For example:
controllers
services
models
routes
middleware
config
views
public
uploads
logs
By documenting this structure, AI will maintain it when adding new features.
Set Your Coding Style Too
Every project has its own coding style.
You can add rules like:
Use camelCase for function names
Use lowercase for filenames
Controllers handle only requests
Services contain business logic only
Handle SQL in Models only
Separate common functions into Helpers
Defining these details ensures AI maintains the same style.
Incorporate Security Rules Too
It’s best to define security rules from the start of your project.
For example:
Item | Rule |
|---|---|
Passwords | Use bcrypt |
Authentication | Use JWT |
Secrets | Store in .env |
SQL | Use Prepared Statements |
File Uploads | Check file extensions |
User Input | Use Validator |
The more your project grows, the more important these rules become.
Standardize Response Formats Too
If you’re building an API, defining response formats upfront is beneficial.
For example:
Success responses
Error responses
Validation errors
Login errors
Documenting these structures in PROJECT.md ensures Claude generates consistent responses.
Include Git Rules Too
It’s also helpful to document your project’s Git rules.
For example:
Rule | Description |
|---|---|
Feature-based commits | Commit in small units |
Protect main branch | Maintain production branch |
Push after feature completion | Upload after testing |
Create CHANGELOG | Track changes |
These rules help both AI and humans when collaborating on development.
The Bigger Your Project, The More Valuable This Becomes
For small projects, not having rules might not cause major issues.
But as your project grows and new features are added continuously, the value of PROJECT.md increases significantly.
Because AI generates new features based on these rules, it helps maintain overall consistency across the entire project.
Vibecoding Is About Creating Rules
Many people think in the AI era they won’t need to code anymore.
But in reality, the ability to design projects and create development rules is becoming even more important.
Good rules lead to good code,
good code reduces refactoring time,
and ultimately increases overall project productivity.
Frequently Asked Questions (FAQ)
Q1. Do I need to create a new PROJECT.md for every project?
Yes. Since each project has different goals and structures, it’s recommended to write one when starting a new project.
Q2. Won’t too many development rules confuse the AI?
No. In fact, clear rules help Claude generate more stable code that fits your project.
Q3. Can I add PROJECT.md to an existing project?
Yes, absolutely. Adding a PROJECT.md to an existing project helps organize development rules, making future AI-assisted maintenance and feature additions much easier.
Closing Thoughts
While being good at refactoring is important,
what’s even more critical is creating a project that requires almost no refactoring.
PROJECT.md isn’t just a document—it’s a blueprint for guiding AI on your project’s standards.
In this lesson, we explored how to use PROJECT.md to guide Claude in generating consistent code from the start.
In our next lesson, we’ll cover automatically generating Swagger (OpenAPI) documentation alongside AI for managing API documentation.
FAQ
Do I need to create a new PROJECT.md for every project?
Yes. Since each project has different goals and structures, it's recommended to write one when starting a new project.
Won't too many development rules confuse the AI?
No. In fact, clear rules help Claude generate more stable code that fits your project.
Can I add PROJECT.md to an existing project?
Yes, absolutely. Adding a PROJECT.md to an existing project helps organize development rules, making future AI-assisted maintenance and feature additions much easier.
Korean Source
This article is an English localization of a Korean-language report from BlogScore. Original: 5강-2 Claude가 처음부터 좋은 코드를 만들게 하는 방법! PROJECT.md 개발 규칙 작성하기