Two Interaction Modes, Two Rule Needs
Modern AI coding tools operate in two fundamentally different modes. Inline mode: tab completion (predict the next few tokens as you type), inline chat (Cmd+K to edit a selected block), and ghost text suggestions (preview of the next line). The interaction is: per-keystroke, single-file, and immediate. The AI needs: quick pattern hints (which import to suggest, which function style to complete with, which naming convention to follow). Agent mode: Composer (plan and implement across files), Claude Code (autonomous multi-step execution), and Cline (approve-per-action multi-file editing). The interaction is: per-task, multi-file, and deliberate. The AI needs: architectural guidance (which patterns across files, which libraries for which purpose, how components interact).
The same CLAUDE.md file serves both modes, but different rules matter for each. For inline: "Use async/await" matters (affects every function the AI completes). "Use cursor-based pagination" does not matter (the AI is completing one line, not designing pagination). For agent: "Use cursor-based pagination" matters (the agent is implementing a feature that needs pagination). "Use async/await" still matters but is less critical (the agent follows it naturally in a larger context). The rule priority: differs by mode even though both modes read the same file.
This article maps: which rules serve inline mode, which serve agent mode, which serve both, and how to structure your rule file so that both modes get the guidance they need. The goal: one rule file that works optimally for tab completion AND multi-file agents.
Rules for Inline Mode: Concise Pattern Hints
Inline mode rules that matter: naming conventions ("camelCase for variables, PascalCase for components" — affects every completion), import patterns ("import from @/ for internal modules" — affects every import suggestion), function style ("use async/await, arrow functions for components, function declarations for utilities" — affects every function completion), type conventions ("use interfaces for object shapes, type for unions" — affects every type suggestion), and error patterns ("throw for unexpected, return Result for expected" — affects error handling completions).
What inline mode does not use: architectural decisions ("use the repository pattern for data access" — inline does not implement patterns, it completes lines), multi-file conventions ("co-locate tests alongside source" — inline operates within one file), library selection rationale ("we chose Zustand because..." — inline needs to know WHICH library, not WHY), and deployment configuration ("deploy to Vercel with edge runtime" — irrelevant for line completion). These rules: consume context tokens without affecting inline output.
For inline optimization: put naming, import, function style, and type rules in the first 200 words of your rule file. These rules fire on: every keystroke, every completion, every inline suggestion. They are: the highest-frequency rules in your file. If the AI context window prioritizes the beginning of the rule file (primacy effect): the inline-relevant rules get the most attention. This ordering benefits: inline mode (high-frequency rules are first) without hurting agent mode (the agent reads the full file anyway).
- Inline needs: naming, imports, function style, types, error patterns — per-keystroke relevant
- Inline ignores: architecture, multi-file, library rationale, deployment — irrelevant for line completion
- Put inline rules first: naming and imports in the first 200 words — primacy effect benefit
- Highest frequency: these rules affect every completion, every suggestion, every inline chat
- Optimization: inline rules first, agent rules after — both modes served from one file
Naming, import, and function style rules affect: every tab completion, every inline suggestion, every ghost text preview. These are the highest-frequency rules in your file. Put them in the first 200 words. Primacy effect: the model pays most attention to the beginning of context.
Rules for Agent Mode: Architectural Guidance and Guardrails
Agent mode rules that matter: architecture patterns ("Server Components default, use client only for interactivity" — the agent decides component boundaries across files), library selection ("Zustand for client state, TanStack Query for server state, React Hook Form for complex forms" — the agent chooses which library to use for each feature), file structure ("feature folders: components/, hooks/, tests/ co-located" — the agent creates files in the correct locations), testing strategy ("unit tests for utilities, integration tests for API routes, component tests with React Testing Library" — the agent generates the right test type), and safety guardrails ("always validate inputs with Zod, never raw SQL, always handle errors" — the agent must follow security rules across all generated files).
What agent mode needs that inline does not: multi-file conventions (how files relate to each other, where to create new files, how to organize imports across modules), task decomposition hints ("for new API endpoints: create route, add Zod schema, add test, update types" — the agent follows this sequence), and scope boundaries ("do not modify files outside the specified package unless explicitly asked" — prevents the agent from making unintended cross-package changes). These rules: guide the agent's planning and execution, not its line-by-line output.
Agent safety guardrails are: the most important agent-specific rules. "Always run tests after making changes" (the agent verifies its work). "Create a git branch before multi-file changes" (the changes are isolated and revertible). "Do not delete files unless explicitly asked" (prevents accidental data loss). "Ask before modifying package.json dependencies" (prevents unintended dependency changes). These guardrails: exist because agents have autonomy. Inline AI cannot delete files or modify dependencies. Agents can — and the guardrails constrain that power.
- Agent needs: architecture, library selection, file structure, testing strategy, safety guardrails
- Multi-file: how files relate, where to create new files, cross-module organization
- Task decomposition: 'for new endpoint: route + schema + test + types' — agent follows sequence
- Safety guardrails: run tests, create branch, do not delete, ask before modifying dependencies
- Guardrails exist because agents have autonomy: inline cannot delete files, agents can
Inline AI cannot delete files or modify dependencies. Agents can. 'Run tests after changes,' 'create a branch first,' 'do not delete unless asked,' 'ask before adding deps' — these guardrails constrain agent autonomy. They are meaningless for inline but critical for agents.
Rules That Serve Both Modes
Universal rules (both modes benefit): technology stack ("TypeScript, Next.js 16, Tailwind CSS" — inline knows which imports to suggest, agent knows which framework patterns to use), naming conventions ("camelCase variables, PascalCase components" — inline follows in completions, agent follows in generated files), error handling philosophy ("throw for unexpected, Result for expected" — inline completes error handling, agent generates error handling), and testing framework ("Vitest" — inline completes test assertions, agent generates test files).
Universal rules should be: at the top of the file (both modes read from the top), concise (benefit inline with minimal token usage), and specific ("Vitest with React Testing Library" not "write tests" — both modes need specifics, not generalities). The universal rules are: the 200-400 word core of your rule file. They power: every inline completion AND every agent task. They are: the highest-ROI rules in the file because they affect the most AI interactions.
The rule file structure for both modes: (1) Universal rules, 200-400 words (stack, naming, types, errors, testing — inline benefits, agent benefits). (2) Agent-specific rules, 200-400 words (architecture, file structure, library selection, safety guardrails — agent benefits, inline ignores). (3) Optional: project-specific context, 100-200 words (domain knowledge, entity relationships — agent benefits for feature-level tasks). Total: 500-1000 words. The universal section: doubles as inline optimization. The agent section: provides the depth for multi-file tasks.
- Universal: stack, naming, types, errors, testing — both modes benefit equally
- Put universal first: 200-400 words, top of file, highest ROI per token
- Agent-specific after: 200-400 words, architecture, file structure, guardrails
- File structure: universal (both) → agent-specific (agents) → project context (optional)
- Total: 500-1000 words. Universal = inline optimized. Agent section = depth for multi-file
Practical Example: One File, Both Modes
The optimized CLAUDE.md: section 1 (Universal, first 300 words): "# Project. Next.js 16, TypeScript strict, Tailwind CSS 4, Drizzle ORM, Neon Postgres. Package manager: pnpm. ## Conventions. camelCase variables/functions. PascalCase components/types. UPPER_SNAKE constants. Async/await, never .then(). Prefer interfaces for objects, type for unions. Import: @/ for internal paths. ## Error Handling. Throw for unexpected errors. Return { data, error } for API responses. Zod validation on every API input. ## Testing. Vitest + React Testing Library. Test files: *.test.ts alongside source."
Section 2 (Agent-specific, next 300 words): "## Architecture. Server Components by default. Add 'use client' only for useState/useEffect/onClick. Narrow client boundaries. ## State. Zustand for global client state. TanStack Query for server state. No Redux. ## File Structure. Feature folders: _components/, _hooks/, _lib/ co-located with route. New component: create file + test file + export from index. ## Agent Guidelines. Run pnpm test after multi-file changes. Create a git branch for features. Do not modify packages outside the current task scope. Ask before adding new dependencies to package.json."
How this serves both modes: inline completion in a .tsx file: the AI reads the universal section (300 words), knows TypeScript strict, camelCase, async/await, @/ imports. Every completion follows these conventions. Agent task ("add a user settings page"): the AI reads both sections (600 words), knows Server Components default, Zustand for state, feature folder structure, and the safety guardrails. The agent creates: page.tsx (Server Component), _components/SettingsForm.tsx (Client Component), _lib/settings-actions.ts (server actions), and settings.test.ts (Vitest). One file, 600 words, optimal for both modes.
Universal (300 words): stack, naming, types, errors, testing. Agent-specific (300 words): architecture, file structure, state, guardrails. Inline reads the top 300 (naming, imports — per-keystroke relevant). Agent reads all 600 (architecture + naming). One file, 600 words, both modes served optimally.
Comparison Summary
Summary of inline AI vs agent AI rule needs.
- Inline: needs naming, imports, function style, types — per-keystroke, highest frequency
- Agent: needs architecture, file structure, library selection, safety guardrails — per-task, multi-file
- Both: stack, naming, error handling, testing — universal rules, highest ROI
- File structure: universal rules first (200-400 words) then agent-specific (200-400 words)
- Inline optimization: universal rules at the top get primacy attention from the model
- Agent guardrails: run tests, create branch, do not delete, ask before adding deps — autonomy constraints
- One file serves both: 500-1000 words total, inline reads the top, agent reads everything
- The question is not inline OR agent rules — it is ORDERING rules so both modes are served optimally