Transform your existing project from inconsistent AI interactions to a personal AI coding assistant that knows exactly how you work
- Clone the workflow repo (if you haven't already):
git clone https://github.com/juehai/cursor-auto-rules-agile-workflow.git
- Apply it to your existing project (non-destructive):
cd cursor-auto-rules-agile-workflow ./apply-rules.sh /path/to/your/project
- Open the project in Cursor and create two starter rules:
"Create a rule that all .mdc files must live in .cursor/rules/"
"Analyze this codebase and create rules that match our existing style"
That’s enough to bootstrap the stdlib system. When you’re ready for the full story, read on.
- Cursor Rules & Stdlib 101
- The Revolution Explained
- Why Most People Use Cursor Wrong
- The Stdlib Philosophy
- Step-by-Step Implementation
- Geoffrey Huntley's Advanced Techniques
- Building Your Personal Stdlib
- Automation Examples
- Advanced Rule Composition
- Real-World Success Stories
- Troubleshooting & Best Practices
If you’re brand-new to Cursor rules, read this section first. In 3 minutes you’ll know exactly what a rule is, where it lives, and why a “stdlib” matters.
- A rule is simply a Markdown file with the extension
.mdc
stored under.cursor/rules/
in your repo. - Each rule has a YAML header that tells Cursor when to load it (
globs
,alwaysApply
) and a body that tells Cursor how to behave. - Every time you chat or run a ⌘/Ctrl-K command, Cursor looks at your rules, injects the relevant ones into its prompt, and follows them.
Minimal rule anatomy
---
description: Always use TypeScript
globs: "*.ts,*.tsx"
alwaysApply: false # true = rule is always active
---
# TypeScript Only
## Critical Rules
- Never create `.js` files; prefer `.ts` or `.tsx`.
Think of the standard library of a programming language—reusable utilities you rely on every day. A Cursor stdlib is the same idea but for prompts: a growing collection of rules that encode your team’s preferences, patterns, and best practices so you never have to repeat yourself.
- Discovery – Cursor automatically scans
.cursor/rules/
before every action. - Selection – It selects rules whose
globs
match the files you’re working on or rules markedalwaysApply: true
. - Injection – The text of those rules is appended to the model’s context so it can obey them.
- Manual override – You can force-apply a rule at any time by referencing its file name with
@rule-name
in chat.
💡 Why Cursor checks even if the folder doesn’t exist?
Cursor’s runtime does a lightning-fast existence check (stat
) on .cursor/rules/
every time it builds a prompt:
- Folder absent → the check returns in microseconds and nothing is loaded (zero cost).
- Folder present → any matching
.mdc
files are injected so the LLM can obey them.
This design means you get instant opt-in: drop a single rule file into .cursor/rules/
and the feature springs to life—no settings, flags, or restarts needed.
- Consistency: Stop re-arguing code style in every PR—rules make decisions once and for all.
- Speed: Cursor remembers your decisions, so you type less and ship faster.
- Compound Power: You can compose small rules like LEGO bricks (e.g.,
typescript-strict + error-handling + jsdoc-standard
). - Knowledge Capture: Every time Cursor slips up, you add/update a rule—mistakes become permanent improvements.
Folder | When it Fires | Typical Content |
---|---|---|
global-rules/ |
Always | Tone, emojis, communication style |
core-rules/ |
Agent decides | Rule generator spec, high-priority meta-rules |
ts-rules/ |
Matches *.ts* |
TypeScript strictness, linting |
tool-rules/ |
Triggered by events | Auto-commit, lint-fix, build hooks |
workflows/ |
Manual @workflow |
Sprint planning, release checklists |
Most developers treat Cursor like a fancy Google Search or autocomplete:
❌ "Hey Cursor, can you please implement user authentication?"
❌ "Could you help me fix this bug?"
❌ "Please create a React component for me"
Result: Inconsistent code, frustrating experience, no learning retention
Instead of asking Cursor to "implement XYZ," you should be building a "stdlib" (standard library) of thousands of prompting rules and composing them together like Unix pipes.
Source: Geoffrey Huntley's stdlib methodology
✅ Build reusable rules that teach Cursor your exact preferences
✅ Compose rules together for complex tasks
✅ Program the AI's behavior instead of fighting it
✅ Create an exponentially improving personal coding assistant
- Using Cursor as Google Search replacement
- Underspecification of prompts - "implement XYZ, please"
- Treating Cursor as an IDE instead of an autonomous agent
- Not knowing you can program LLM outcomes
- Unnecessary pleasantries ("please" and "can you")
"You can ask Cursor to write rules and update rules with learnings as if your career depended upon it." - Geoffrey Huntley
His Results in 8 Hours:
- Automatic git commits with conventional format
- Automated DNS record authoring and deployment
- Autonomous Linux kernel patching
- Automated code formatting and linting
- Custom build system automation
- Pre-commit failure handling
# Instead of this massive prompt:
"Create a TypeScript React component with error handling, JSDoc comments, proper typing, and our company's naming conventions"
# You compose rules like this:
typescript-strict + react-functional + error-handling + jsdoc-standard + company-naming
"Instead of approaching Cursor from the angle of 'implement XYZ of code' you should instead be thinking of building out a 'stdlib' of thousands of prompting rules and then composing them together like unix pipes."
Each rule you create:
- ✅ Improves every future interaction
- ✅ Compounds with other rules
- ✅ Creates consistent, predictable outcomes
- ✅ Teaches Cursor your exact preferences
Before we dive into commands, here’s what this repo actually injects into your codebase and why it matters:
Piece | What it is | Why you care |
---|---|---|
apply-rules.sh / .bat |
One-liner setup script | Copies everything below into your repo without touching your existing code |
.cursor/rules/ |
Pre-built rule standard-library | Core rule-generator, sample folders (global-rules , ts-rules , tool-rules , ui-rules , workflows ) ready to tweak or delete |
.cursor/templates/ |
Story / PRD / Architecture markdown templates | Keeps planning docs consistent; excluded from indexing to save context tokens |
docs/workflow-rules.md |
Quick reference documentation | Explains rule types, best-practice prompts, and agile workflow |
xnotes/ |
Example project notes | Shows how to structure brainstorming and user stories |
.gitignore , .cursorignore , .cursorindexingignore patches |
Auto-ignore heavy or private files | Prevents accidental commits and keeps the LLM context clean |
In short: run one script → get a fully-organized rule ecosystem + starter docs. No manual folder wrangling, no risk of overwriting your code.
Navigate to the cloned repository:
cd cursor-auto-rules-agile-workflow
Apply to your existing project (100% safe):
# Replace with your actual project path
./apply-rules.sh /path/to/your/existing/project
# Examples:
./apply-rules.sh ~/my-react-app
./apply-rules.sh /home/neo/projects/my-web-app
./apply-rules.sh ../my-existing-project
What this adds to your project:
your-existing-project/
├── .cursor/
│ ├── rules/ # ← NEW: Your stdlib foundation
│ │ ├── core-rules/ # ← Rule generation engine
│ │ ├── global-rules/ # ← Always-applied rules
│ │ ├── ts-rules/ # ← TypeScript-specific rules
│ │ ├── documentation/ # ← Markdown rules
│ │ ├── tool-rules/ # ← Automation rules
│ │ ├── ui-rules/ # ← React/UI rules
│ │ └── workflows/ # ← Manual processes
│ └── templates/ # ← Project templates
├── docs/ # ← Documentation
├── xnotes/ # ← Planning notes
├── YOUR_EXISTING_CODE/ # ← UNCHANGED ✅
└── YOUR_EXISTING_CONFIG/ # ← UNCHANGED ✅
Open your project in Cursor and create the foundation rule:
"Create a rule that describes where to store Cursor rules and ensures all .mdc files are placed in .cursor/rules/ directory with proper naming conventions."
This creates the rule that teaches Cursor where and how to create future rules.
Analyze your existing codebase:
"Analyze all files in this project and create rules that ensure future code follows the same patterns, naming conventions, architecture decisions, and coding style we've already established."
This creates rules based on your existing code patterns.
Essential rules to start with:
1. Language Preferences:
"Never create JavaScript files. Always use TypeScript or JSON only. If you try to create a .js file, stop and ask why TypeScript wouldn't work instead."
2. Error Handling Standard:
"Always wrap async functions in try-catch blocks with specific error types and meaningful logging that includes context information."
3. Documentation Standard:
"Always add JSDoc comments to functions with @param and @returns descriptions. Include usage examples for complex functions."
4. Component Architecture:
"When creating React components, always use functional components with TypeScript interfaces for props, include proper error boundaries, and use React.memo for performance optimization."
Example: Auto License Headers
"When you create any new file, automatically suggest adding our company copyright header with the current year and proper SPDX license identifier."
Example: Database Operations
"When I ask for database operations, always suggest using our ORM patterns, include transaction handling with proper rollback, and add comprehensive error logging."
Auto Git Commits (Geoffrey Huntley's Technique):
"After successful builds and tests, automatically suggest git commit messages using conventional commit format with proper type (feat/fix/docs/refactor) and scope based on the files changed."
Auto Code Review:
"When I ask you to review code, always check against our established rules and suggest improvements for performance, security, maintainability, and adherence to our coding standards."
Block Unwanted Suggestions:
"Never suggest using Webpack for this project. We use Vite for all builds. If build configuration is needed, always recommend Vite-based solutions."
Enforce Architecture Decisions:
"This project uses the repository pattern for data access. Never suggest direct database calls in components. Always use the established service layer and repository interfaces."
When Cursor makes mistakes:
"I asked you to create a test file and you put it in the wrong directory. Create a rule that all test files must be placed in __tests__ folders next to the files they test, following our existing pattern."
This creates rules with specific context about mistakes, helping Cursor learn better.
Day 1-2: Core Language Standards
"Always use const for variables that don't change, let for variables that do. Never use var."
"Use meaningful variable and function names that explain intent, not implementation."
"Prefer explicit typing over any in TypeScript. If you must use any, add a comment explaining why."
Day 3-4: Architecture Patterns
"Separate business logic from UI components. Create custom hooks for stateful logic."
"Use the single responsibility principle - each function should do one thing well."
"Group related functionality into feature folders with index.ts for clean imports."
Day 5-7: Quality Standards
"Always include unit tests for utility functions and integration tests for API endpoints."
"Use descriptive test names that explain what is being tested and expected outcome."
"Include error cases in all tests, not just happy path scenarios."
API Development:
"Always validate input data using Zod schemas before processing."
"Include rate limiting and authentication checks for all endpoints."
"Use consistent HTTP status codes and error response formats."
React Development:
"Use React.memo for components that receive complex props or render frequently."
"Always include error boundaries for route components and data fetching."
"Use useCallback and useMemo appropriately to prevent unnecessary re-renders."
Database Operations:
"Always use transactions for operations that modify multiple tables."
"Include proper indexing suggestions when creating new queries."
"Add connection pooling and query optimization recommendations."
Build & Deploy:
"Before suggesting any build changes, check our existing CI/CD pipeline and maintain compatibility."
"Always include environment-specific configuration options."
"Suggest automated testing and code quality checks for all deployments."
Code Quality:
"Run prettier and ESLint before any commits. Suggest fixing all linting errors."
"Include pre-commit hooks that prevent commits with console.log statements in production code."
"Suggest performance optimizations when adding new dependencies or complex computations."
---
description: Automatically commit changes with conventional commit format
globs: "*"
alwaysApply: false
---
# Auto Git Commit Rule
## Context
- Applies after successful builds and tests
- Uses conventional commit format
- Extracts commit type from change context
## Critical Rules
- Always use conventional commit format: type(scope): description
- Extract change type from context (feat/fix/docs/refactor/test/chore)
- Include meaningful scope based on file path or component
- Write description in imperative mood
## Examples
### ✅ Good Commits
feat(auth): add user authentication with JWT tokens
fix(api): resolve incorrect date parsing in user service
docs(readme): update installation instructions
refactor(utils): extract common validation logic
test(auth): add integration tests for login flow
### ❌ Bad Commits
"Update stuff" "Fix bug" "Changes" "WIP"
## Automation Logic
- After successful build/test: suggest commit
- Analyze changed files to determine scope
- Use change description to determine type
- Format as: type(scope): description
---
description: Automatically add license headers to new files
globs: "*"
alwaysApply: true
---
# Auto License Header
## Critical Rules
- Add copyright header to all new source files
- Use current year and company information
- Include proper SPDX license identifier
- Format according to file type (comments style)
## Examples
### TypeScript/JavaScript Files:
```typescript
/**
* Copyright (c) 2025 Your Company Name. All rights reserved.
* SPDX-License-Identifier: MIT
*/
#!/bin/bash
# Copyright (c) 2025 Your Company Name. All rights reserved.
# SPDX-License-Identifier: MIT
"""
Copyright (c) 2025 Your Company Name. All rights reserved.
SPDX-License-Identifier: MIT
"""
---
## Advanced Rule Composition
### **The Unix Pipe Approach**
**Instead of complex prompts, compose simple rules:**
"Create a TypeScript React component for user authentication with error handling, proper typing, JSDoc comments, unit tests, and our company's naming conventions"
Apply: typescript-strict + react-functional + error-handling + jsdoc-standard + unit-testing + company-naming + auth-patterns
### **Complex Composition Examples**
**Full-Stack Feature Development:**
Base Rules: typescript-strict + error-handling + jsdoc-docs
- Frontend: react-functional + state-management + ui-patterns
- Backend: api-standards + database-transactions + auth-middleware
- Testing: unit-tests + integration-tests + e2e-scenarios
- Deploy: build-optimization + env-config + ci-cd-integration
**Code Review Process:**
Analysis Rules: code-quality + security-check + performance-review
- Standards: naming-conventions + architecture-patterns + documentation-check
- Testing: test-coverage + edge-cases + error-scenarios
- Suggestions: optimization-hints + refactoring-opportunities + best-practices
---
## Real-World Success Stories
### **Geoffrey Huntley's 8-Hour Transformation**
**What he automated:**
1. **Git Workflow:** No more manual commits - automatic conventional commits
2. **Infrastructure:** Automated DNS records and deployment
3. **Build System:** Nix-based builds with automatic testing
4. **Code Quality:** Automatic formatting, linting, and license headers
5. **Debugging:** Step-by-step debugging workflows for complex systems
6. **Package Management:** Automated vendoring and dependency management
**His Quote:**
> "I'm inches away from being able to compose high-level requirements to automatically build a website, configure DNS and automatically deploy infrastructure now that I've been able to rig Cursor to bring in a jackpot every time I pull the lever."
### **Team Implementation Success Pattern**
**Month 1:** Individual developer builds personal stdlib
- 50+ rules covering coding standards, patterns, preferences
- Consistent code output, fewer style discussions in code reviews
**Month 2:** Team adopts shared stdlib base
- Common rules for architecture, testing, deployment
- New team members productive immediately
**Month 3:** Advanced automation
- Auto-commits, auto-testing, auto-deployment suggestions
- Focus shifts from "how to code" to "what to build"
**Month 6:** Exponential productivity
- Complex features built by composing high-level requirements
- AI handles implementation details perfectly
- Team velocity increases 3-5x
---
## Troubleshooting & Best Practices
### **Common Issues & Solutions**
**Problem: Too many rules making Cursor slow**
- Start with 5-10 core rules, add 1-2 per day
- Use specific `globs` patterns to limit scope
- Remove redundant rules as patterns become natural
**Problem: Rules conflicting with each other**
- Be specific about when each rule applies
- Use priority levels in rule metadata
- Test rule combinations before finalizing
**Problem: Rules not applying consistently**
- Check YAML frontmatter syntax
- Verify file placement in `.cursor/rules/`
- Use descriptive `description` fields for agent-selected rules
### **Geoffrey Huntley's Pro Tips**
**1. Start with Rule Location Rule:**
Every project should first have a rule that teaches Cursor where to store rules
**2. Be Specific and Contextual:**
"Use good error handling"
"Wrap all async database operations in try-catch blocks with specific error types (DatabaseError, ValidationError) and log with request ID for tracing"
**3. Learn from Every Mistake:**
When Cursor does something wrong, immediately create a rule to prevent it
**4. Compose, Don't Repeat:**
Build small, focused rules that work together rather than large monolithic ones
**5. Automate Incrementally:**
Start with suggestions, evolve to automation as confidence grows
### **Success Indicators**
**You'll know your stdlib is working when:**
- ✅ Cursor consistently follows your exact coding patterns
- ✅ New team members understand your codebase immediately
- ✅ Code reviews focus on business logic, not style
- ✅ You can ship features faster with fewer bugs
- ✅ Cursor suggests improvements aligned with your standards
- ✅ Complex tasks become simple rule compositions
---
## The Future Vision
### **Geoffrey Huntley's End Goal:**
> "A moment where I can unleash 1000 concurrent cursors/autonomous agents on a backlog is not too far off... the future is developer tooling departing from what we have today - the IDE - towards reviewing PRs from 1000 agents that are autonomously smashing out the backlog, in parallel."
### **Your Journey Progression:**
**Week 1:** Basic rule creation and application
**Month 1:** Personal stdlib with 50+ rules
**Month 3:** Advanced automation and rule composition
**Month 6:** Complex feature development through high-level requirement composition
**Year 1:** Teaching other developers and scaling team productivity
### **The Compound Effect:**
Each rule you create:
- Improves every future interaction
- Compounds with existing rules
- Creates exponentially better outcomes
- Builds toward fully autonomous development assistance
---
## Getting Started Checklist
### **Immediate Actions (Next 30 Minutes):**
1. **✅ Apply the foundation to your existing project:**
```bash
cd cursor-auto-rules-agile-workflow
./apply-rules.sh /path/to/your/existing/project
-
✅ Create your first rule:
"Create a rule that describes where to store Cursor rules and ensures proper organization of .mdc files in .cursor/rules/"
-
✅ Analyze your existing codebase:
"Analyze this project and create rules that match our existing coding patterns, naming conventions, and architecture decisions."
- 5 core coding standard rules
- 3 architecture pattern rules
- 2 documentation rules
- 1 automation rule
- 50+ active rules covering all aspects of development
- Automatic rule application working smoothly
- Consistent, high-quality code output
- Reduced time spent on style/pattern decisions
- Rule composition for complex features
- Automated workflows (commits, testing, deployment)
- Team stdlib sharing and collaboration
- Domain-specific rule libraries
- Reddit inspiration: Thanks to u/LilienneCarter whose comment introducing Cursor rules helped start this entire exploration.
- Geoffrey Huntley's Original Article – The foundational stdlib methodology
- Cursor Auto Rules Repository – Implementation framework
- Geoffrey Huntley's Twitter – Latest updates and insights
🎉 Welcome to the Cursor AI Revolution!
You're about to transform from using Cursor as a fancy autocomplete to having a personal AI development assistant that knows exactly how you work, thinks, and code.
The journey from inconsistent AI interactions to exponential productivity starts with your first rule.
Happy Coding! 🚀
This guide combines the practical implementation framework from the cursor-auto-rules-agile-workflow repository with Geoffrey Huntley's advanced stdlib methodology. Referenced from Geoffrey Huntley's stdlib methodology and implementation patterns.