AI Efficiency Handbooks
repository·main·Indexed 41 days ago
https://github.com/abhisheksinha1506/ai-efficiency-handbooksA collection of handbooks for optimizing AI-assisted software engineering workflows, specifically for Cursor AI and Claude Code. It provides guidance on creating .cursorrules and .mdc files, implementing high-performance development workflows, and utilizing advanced prompting techniques like 'vibe coding' and 'Contemplative Reasoning' to improve AI agent reliability and prevent context rot.
What's inside AI Efficiency Handbooks
- The AI Efficiency Handbooks is a knowledge base designed for AI-assisted software engineering, specifically optimized for tools like Cursor AI and Claude Code. It provides high-performance development workflows, 'vibe coding' practices, and advanced prompting techniques to help developers use AI agents as proactive partners.
Implement the "External Memory" System for Project State
mainDo not rely on the ephemeral chat window for project state. Instead, offload memory to specific files that act as the project's "brain". Use these files to maintain context across sessions:
File Purpose Usage PROJECT_OVERVIEW.mdCore Architecture Reference for directory tree, tech stack, and data flow. MILESTONES.mdRoadmap & Checklist High-level phases and trackable task status. DOCUMENTATION.mdAPI & Schema Registry Prevents hallucination of API contracts or DB relations. CURSOR_MEMORY.mdPersistence Record project lessons and principles to avoid repeating mistakes. Configure Cursor Rule Layering Strategy
mainFor maximum effectiveness, do not put all rules in one place. Use a layered approach to ensure the AI respects both personality and technical context.
Layer Responsibility Recommended Content Global Rules (Settings) Discipline & Personality Thinking style, planning discipline, verbosity, and output format. Project Rules ( .cursor/rules/*.mdc)Knowledge & Context Tech-stack specifics (e.g., Next.js, Tailwind), naming conventions, and project architecture. Note: Avoid using the legacy
.cursorrulesfile at the root, as it is often ignored or diluted compared to the modern.mdcsystem.How Cursor rule application works
mainUnderstanding how Cursor injects rules is critical for troubleshooting why instructions are ignored or causing context issues:
- Selective Injection: Rules are only added to the LLM's system prompt if the
globspattern matches the currently active file or if the rule hasalwaysApply: trueset in its frontmatter. - Context Dilution: Using overly broad patterns like
globs: "**/*"can flood the context window. This causes weaker or longer rules to be truncated or pushed out of the model's immediate attention. - Hierarchy Priority:
- Global Rules (Settings): Highest priority; treated as fundamental system instructions.
.mdcfiles: Project-specific context.- Legacy
.cursorrules: Lowest priority.
- Selective Injection: Rules are only added to the LLM's system prompt if the
Adopt the Vibe Coding mindset
mainVibe coding is a high-velocity development approach that balances momentum with engineering discipline. It relies on three distinct modes of operation:
- Farmer Mode (The Setup): Prepare a 'Boring' stack (e.g., Next.js, Python/Node, Tailwind) that the AI has extensive training data for. This ensures the AI operates within predictable logical bounds.
- Chef Mode (The Flow): Provide high-level goals and let the AI propose implementation details. Avoid micromanaging implementation to allow the AI's 'native' solutions to shine.
- Review Mode (The Taste): Actively taste and adjust. If the AI suggests a bad pattern, fix it immediately to prevent technical debt from compounding.
Apply the Hybrid Planning Protocol
mainFollow a
Plan→Execute→Critique→Iteratestate machine for complex features:- Planning (High-Energy/Human): Manually plan complex features, data models, and core logic. Ensure architecture is solid before coding.
- Execution (Low-Energy/AI Agent): Switch to Agent Mode once the plan is set. The AI acts as a high-speed junior developer for implementation details.
- The "Roast" Critique Loop: After the AI writes code, do not run it immediately. Use a self-review prompt to catch bugs.
- Prompt:
"Roast this code. Critique it for bugs, security holes, and readability like a senior engineer."
- Prompt:
"Roast this code. Critique it for bugs, security holes, and readability like a senior engineer."Apply the Core Prompting Formula
mainFor optimal results, every prompt should contain these four elements:
- Role: Define the persona (e.g., "Act as a Senior React Engineer").
- Task: Define the specific action (e.g., "Create a reusable DatePicker component").
- Constraints: Define the tech stack and rules (e.g., "Use Tailwind, TypeScript, and date-fns").
- Format: Define the output style (e.g., "Output only the code file, no explanation").
How Global and Project Rules work together
mainEffective Cursor rule management relies on a layered architecture that separates Behavior from Knowledge:
- Global Rules (Behavior Layer): Set in Cursor Settings. These define how the AI thinks and communicates (e.g., 'Think step-by-step', 'Never use placeholders'). They are injected into every request.
- Project Rules (Knowledge Layer): Stored as
.mdcfiles in.cursor/rules/. These define what the AI knows about your specific project (e.g., 'Use Next.js 14', 'Use PascalCase for components'). They are loaded selectively based on file context/globs to keep the context window clean.
By separating these, you avoid 'context dilution' where specific project knowledge gets buried by general instructions.
Implement a persistent Memory System with `project-memory.md`
mainTo prevent context loss and hallucinations, use a single persistent markdown file named
project-memory.md. This acts as the AI's long-term memory.File Structure
Include these sections in
project-memory.md:- Architecture: Core tech stack and folder duties.
- Patterns: Coding standards (e.g., "Use Server Actions", "Use strict Types").
- Decisions: Rationale for tech choices (e.g., "Why we chose Prisma over Drizzle").
- Lessons: Learned mistakes (e.g., "Never use
anyin API routes"). - Tech Debt: Known hacks to fix later.
Workflow Routine
- Start of Session: Reference the file and the task:
@project-memory.md + Current Task: [Describe]. Follow patterns exactly. - End of Session: Instruct the AI to update the file:
Summarize today's progress, key decisions, and new lessons. Append to @project-memory.md.
@project-memory.md + Current Task: [Describe]. Follow patterns exactly.How the Cursor Reliability Hierarchy works
mainWhen deciding where to place instructions, use the following hierarchy to ensure maximum compliance from the AI:
- Global "Rules for AI" (Highest Reliability ⭐⭐⭐⭐⭐): Best for Personality & Thinking Style. Use this for high-level instructions like "Think step-by-step" or "Explain before code."
.cursor/rules/*.mdc(High Reliability ⭐⭐⭐⭐): Best for Knowledge & Context. Use these modular files for tech stacks, architecture patterns, naming conventions, and library-specific usage.- Legacy
.cursorrules(Low Reliability ⭐⭐): Best for Legacy Root Config. This is still supported but is often deprioritized by the model compared to the modular.mdcsystem.
Implement a Hierarchical Memory Architecture
mainTo prevent context rot and hallucinations, organize project knowledge into a hierarchy of specialized markdown files. This allows the AI to access high-level architecture and low-level implementation details without overloading the active context window.
CLAUDE.md(The "Bible"): Repository-level configuration. Store build commands, test commands, and code style guidelines here.ARCHITECTURE.md(The Brain): A single-page source of truth for architectural patterns and major technical decisions.PROJECT_INTELLIGENCE.md: A living document to track technical debt, recent decisions, and evolving patterns. Reference this at the start of every session.thoughts/Directory: A persistent directory for the AI to perform
Use the Antigravity Meta-Prompting framework for instruction adherence
mainAntigravity meta-prompting adds a layer of self-policing instructions that forces the model to verify its own compliance before generating output.
For production-ready engineering workflows, use the Self-Compliance Protocol variant. This version is designed to avoid common AI failures like using placeholders (e.g.,
// rest of code here), using ellipses, or providing incomplete/non-runnable code.When to use:
- ✅ Complex Refactoring: When the model misses strict naming or architectural patterns.
- ✅ Messy Codebases: When the AI tends to skip lines or logic.
- ✅ Subtle Bug Hunting: For structured deep-dives.
- ❌ Simple Q&A: Too much token overhead.
- ❌ Creative Tasks: The rigid structure may stifle brainstorming.
# Self-Compliance Protocol Before every response, you must internally verify: 1. Is full step-by-step reasoning shown? 2. Are there ZERO placeholders, ellipses, or "rest unchanged"? 3. Is code complete and runnable? 4. If any check fails, rewrite your response until perfect. Start every output with: `[COMPLIANCE CHECK: PASSED]`