$ man how-to/rules-skills-context

IDE Fundamentalsintermediate

Rules, Skills, and Context Files

The three layers that turn a generic AI into your AI


The Three Layers

There are three layers of configuration that shape how AI behaves in your IDE. Each layer loads at a different time and serves a different purpose. Rules load automatically based on what files you are editing. They enforce patterns without you thinking about them. Skills load when you invoke them with a slash command or keyword. They execute specific workflows step by step. Context files (like CLAUDE.md) load at the start of every session and set the baseline for everything else. Together, these three layers replace the need to re-explain your preferences, workflows, and constraints every session. You set them up once. They work every time.
PATTERN

Rules: Automatic Pattern Enforcement

Rules are files that load based on glob patterns. When you open a TypeScript file, the TypeScript rule loads. When you edit a blog post, the blog formatting rule loads. You never invoke them manually. They activate based on what you are touching. In Cursor, rules live in .cursor/rules/ as .mdc files with frontmatter that specifies the glob pattern. In Claude Code, they live in .claude/rules/ or are defined in the CLAUDE.md file. The format differs. The concept is identical. Good rules are narrow and specific. "When editing files in content/drafts/, enforce the date-prefix naming convention and voice guide adherence." Bad rules are broad and generic. "Always write good code." Narrow rules produce consistent behavior. Broad rules produce inconsistent results because the AI interprets "good" differently every session.
PATTERN

Skills: On-Demand Workflow Execution

Skills are markdown files that define step-by-step workflows. You invoke them explicitly. Type /deploy and the deploy skill loads. Type /tracker and the tracker skill loads. Each skill contains everything the agent needs to execute that workflow: what files to read, what commands to run, what output to produce, and how to handle errors. The skill file is the entire workflow in plain English. You are not writing code. You are writing instructions that an AI agent follows. "Step 1: Check for unstaged changes. Step 2: Stage all modified files. Step 3: Generate a commit message from the diff." The agent reads these steps and executes them. Skills compound. Every time you use a skill and notice an edge case, you fix the skill. After 20 uses, the skill handles scenarios you never planned for. That is the cast iron skillet pattern. The skill gets more seasoned with use.
PRO TIP

Context Files: Session Baseline

Context files like CLAUDE.md load before anything else. They set the defaults for every session. Environment information (OS, shell, language preferences), code style rules, and behavioral constraints. Keep context files lean. Only put things here that apply to EVERY session. If a rule only applies when editing blog posts, it belongs in a rule file, not CLAUDE.md. If a workflow only runs when you type /deploy, it belongs in a skill file, not CLAUDE.md. The hierarchy: CLAUDE.md sets the floor. Rules adjust for file types. Skills execute specific workflows. Each layer adds context without overloading the context window with irrelevant information. The agent gets exactly what it needs for the current task.
ANTI-PATTERN

Common Setup Mistakes

Putting everything in CLAUDE.md. Your CLAUDE.md becomes 500 lines and the agent reads all of it every session, even when 90% is irrelevant. Move workflow instructions to skills. Move file-specific patterns to rules. Keep CLAUDE.md under 50 lines. Writing skills that are too vague. "Deploy the website" is not a skill. It is a wish. Write specific steps with specific commands and specific success criteria. Not using rules at all. If you find yourself repeating the same instruction across sessions ("use TypeScript, not JavaScript"), that should be a rule. Rules automate the repeated instructions so you never have to type them again.

knowledge guide
See "Cursor" in Knowledge See "Context" in Knowledge

related guides
Getting Started with CursorIDE Principles That TransferClaude Code Quickstart
← how-to wikiknowledge guide →
ShawnOS.ai|theGTMOS.ai|theContentOS.ai
built with Next.js · Tailwind · Claude · Remotion