Snippet Management
You are building a new React component and you type useState for the fifth time today. Tab completion fills in the hook, but you still have to manually add the TypeScript types, the initial value, and the pattern for handling loading and error states. Every component starts with the same 15-line boilerplate, and every time you write it slightly differently. Meanwhile, your teammate structures their components a different way entirely.
Snippets solve the boilerplate problem, but traditional VS Code snippets are static templates that do not adapt to your project’s patterns. When you combine snippets with Cursor’s AI, you get dynamic code generation that follows your conventions automatically.
What You’ll Walk Away With
Section titled “What You’ll Walk Away With”- A snippet strategy that combines VS Code snippets with Cursor rules for maximum speed
- Copy-paste rules that turn common patterns into instant boilerplate
- Techniques for generating and managing project-specific snippets
- Workflow patterns for using snippets alongside AI-generated code
The Two-Layer Snippet Strategy
Section titled “The Two-Layer Snippet Strategy”Layer 1: VS Code Snippets for Muscle Memory
Section titled “Layer 1: VS Code Snippets for Muscle Memory”Use traditional VS Code snippets for patterns you type dozens of times per day. These are instant (no AI round-trip) and deterministic (same output every time):
{ "React Functional Component": { "prefix": "rfc", "scope": "typescriptreact", "body": [ "interface ${1:Component}Props {", " $2", "}", "", "export function ${1:Component}({ $3 }: ${1:Component}Props) {", " $0", " return (", " <div>", " ", " </div>", " )", "}" ] }}Store project-specific snippets in .vscode/project.code-snippets and check them into version control.
Layer 2: Cursor Rules for Smart Boilerplate
Section titled “Layer 2: Cursor Rules for Smart Boilerplate”For patterns that need to adapt to context (the right imports, the right types, the right error handling for this specific project), use Cursor rules instead of static snippets:
---description: Generate boilerplate for a new API route handleralwaysApply: false---
When I ask you to create a new route handler, generate this structure:
1. Import the required middleware from @src/middleware/2. Import the Zod schema from @src/schemas/3. Import the service from @src/services/4. Create the handler with proper TypeScript types5. Add validation, authentication, error handling6. Follow the exact pattern in @src/routes/users.ts
This rule generates context-aware boilerplate, not static templates.Generating Snippets with AI
Section titled “Generating Snippets with AI”Let Cursor analyze your codebase and generate snippets based on your actual patterns:
Snippet Workflows
Section titled “Snippet Workflows”The Quick Component Workflow
Section titled “The Quick Component Workflow”- Type the snippet prefix (
rfcfor a React component) - Tab through the placeholders to set the component name and props
- Press
Cmd+Kto fill in the component body with AI: “fetch user notifications and display them in a list” - Tab to accept the AI suggestion
This combines the speed of snippets (instant boilerplate) with the intelligence of AI (context-aware implementation).
The Pattern Replication Workflow
Section titled “The Pattern Replication Workflow”When you need to create something that follows an existing pattern:
- Open the file you want to replicate
- Press
Cmd+Shift+Lto add it as context - Open a new file
- Tell Agent: “Create a [new thing] following the exact pattern in the file I added as context”
This is effectively a “smart snippet” that adapts the template to your specific needs.
When This Breaks
Section titled “When This Breaks”Snippets conflict with Tab completion. If a VS Code snippet prefix conflicts with Cursor’s Tab suggestions, the snippet takes priority. Choose unique prefixes that do not overlap with common code tokens.
AI-generated boilerplate drifts from snippets. When your rules and snippets describe different patterns, developers get inconsistent output. Keep them aligned: when you update a snippet, update the corresponding rule.
Too many snippets slow down autocomplete. If you have 100+ snippets, the autocomplete dropdown becomes noisy. Prefix snippets by category (api-, comp-, test-) so you can type the category to filter.
What’s Next
Section titled “What’s Next”- Context Patterns — Using existing files as living templates
- Prompt Templates — Reusable prompts that complement snippets
- Time Savers — More workflow optimizations that save daily time