Skip to content

Advanced Techniques: Tips 91-105

These expert-level techniques push Cursor to its limits, enabling automation workflows, custom integrations, and enterprise-grade development practices. Master these to become a true Cursor power user.

Choose models based on task complexity and requirements:

// Simple code completion
Model: cursor-small
Use case: Tab completions, simple edits
Speed: under 100ms
Cost: Lowest
// Standard development
Model: claude-3.5-sonnet
Use case: Most coding tasks, refactoring
Speed: 1-3s
Cost: Moderate
// Complex reasoning
Model: claude-3-opus
Use case: Architecture, complex algorithms
Speed: 3-5s
Cost: 5x Sonnet
// Deep analysis
Model: o3-mini
Use case: Debugging complex issues
Speed: 5-10s
Cost: Premium

Tip 92: Optimize Token Usage with Context Strategies

Section titled “Tip 92: Optimize Token Usage with Context Strategies”

Maximize efficiency while minimizing costs:

// Context compression techniques
// 1. Use summary files
// Instead of: @entire-module
// Create: module-summary.md with key points
// 2. Progressive context loading
'First, analyze the high-level structure of @src/index.ts' /
// Then: "Now look at the specific implementation of processData"
// 3. Selective file inclusion
// Instead of: @folder:src
// Use: @src/core/**.ts @src/api/routes.ts
// 4. Clear context regularly
clear -
context;
// Or start new chat for unrelated tasks

Cost Tip Monitor token usage: Ctrl+Shift+J → Usage tab

Ensure reliability with fallback chains:

{
"cursor.models.fallbackChain": [
{
"primary": "claude-3-opus",
"fallbacks": ["claude-3.5-sonnet", "gpt-4"]
},
{
"primary": "o3",
"fallbacks": ["claude-3-opus", "claude-3.5-sonnet"]
}
],
"cursor.models.autoSwitch": {
"enabled": true,
"onRateLimit": true,
"onError": true
}
}

Create specialized tools for your workflow:

  1. Set up MCP project

    Terminal window
    mkdir my-mcp-server
    cd my-mcp-server
    npm init -y
    npm install @modelcontextprotocol/sdk
  2. Create server implementation

    index.ts
    import { Server } from '@modelcontextprotocol/sdk/server/index.js';
    import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
    const server = new Server({
    name: 'my-custom-mcp',
    version: '1.0.0',
    });
    // Add custom tools
    server.setRequestHandler('tools/list', async () => ({
    tools: [
    {
    name: 'custom_analysis',
    description: 'Analyze codebase for patterns',
    inputSchema: {
    type: 'object',
    properties: {
    pattern: { type: 'string' },
    },
    },
    },
    ],
    }));
    // Handle tool execution
    server.setRequestHandler('tools/call', async (request) => {
    // Implementation
    });
    const transport = new StdioServerTransport();
    await server.connect(transport);
  3. Register in Cursor

    {
    "mcpServers": {
    "my-custom-mcp": {
    "command": "node",
    "args": ["/path/to/my-mcp-server/index.js"]
    }
    }
    }

Tip 95: Integrate External Services via MCP

Section titled “Tip 95: Integrate External Services via MCP”

Connect Cursor to your infrastructure:

Database MCP

// Query your database directly
"Show user growth over last 30 days from our production database"

Monitoring MCP

// Access metrics and logs
"Analyze error patterns in DataDog logs from last hour"

CI/CD MCP

// Trigger deployments
"Deploy feature branch to staging after tests pass"

Create powerful workflows by combining MCPs:

// Example: Full stack feature implementation
"Using @figma-mcp get the new dashboard design,
then implement the frontend components,
use @database-mcp to create required tables,
and @linear-mcp to update the task status"
// The AI orchestrates across multiple tools:
// 1. Fetches design from Figma
// 2. Generates React components
// 3. Creates database migrations
// 4. Updates project management

Use AI to maintain and evolve rules:

// Self-improving rules
"Analyze the last 50 chat conversations and identify
common patterns that should become project rules"
// Context-aware rules
"Based on @src codebase analysis, generate rules for:
- Naming conventions used
- Error handling patterns
- Testing strategies
- Architecture decisions"
// Team learning
"Review recent pull requests and extract coding
standards that should be added to our rules"

Create sophisticated rule logic:

.cursor/rules/conditional-rules.yaml
rules:
- name: 'API Development'
condition:
filePattern: '**/api/**'
contains: ['express', 'fastify']
content: |
Always include:
- Request validation using Joi or Zod
- Standardized error responses
- OpenAPI documentation
- name: 'React Components'
condition:
filePattern: '**/*.tsx'
hasImport: 'react'
content: |
Follow these patterns:
- Functional components only
- Custom hooks for logic
- Props interfaces with JSDoc
- name: 'Database Operations'
condition:
anyOf:
- contains: ['prisma', 'sequelize']
- filePattern: '**/repository/**'
content: |
Ensure all queries:
- Use parameterized queries
- Include transaction handling
- Have proper error handling

Build complex rule hierarchies:

.cursor/rules/base/security.md
// Base rules that others extend
"All API endpoints must validate authentication"
// Specific rules that inherit
// .cursor/rules/api/public-endpoints.md
"@inherit base/security
Exception: Public endpoints listed in config/public-routes.json
Additional: Rate limit all public endpoints to 100 req/min"
// Composite rules
// .cursor/rules/feature/payment.md
"@compose [base/security, api/validation, patterns/repository]
Additional payment-specific rules:
- PCI compliance patterns
- Audit logging for all transactions
- Idempotency keys required"

Use Cursor’s Agent mode for comprehensive code reviews:

# Example pre-commit hook that opens Cursor for review
#!/bin/bash
# Get staged changes
git diff --cached > staged_changes.diff
# Open Cursor with the changes file
cursor staged_changes.diff
# In Cursor, use Agent mode (Ctrl+I) with this prompt:
# "Review the changes in this diff file for:
# - Security vulnerabilities
# - Performance issues
# - Code style violations
# - Missing tests
# - Documentation needs
#
# Use @Git to see recent changes and @Lint Errors to check for issues"

Alternative workflow using Cursor’s built-in features:

  1. Open Agent mode with Ctrl+I
  2. Reference changes with @Git or @Recent Changes
  3. Ask for specific review criteria
  4. Use Apply to implement suggested fixes

Set up automated improvement cycles:

// Scheduled task for code improvement
"Every day at 6 PM:
1. Find the most complex function (cyclomatic complexity)
2. Refactor it to reduce complexity
3. Ensure all tests still pass
4. Create a PR with the changes"

Tip 102: Build Custom Development Pipelines

Section titled “Tip 102: Build Custom Development Pipelines”

Orchestrate complex development workflows:

graph LR A[Jira Ticket] --> B[AI Planning] B --> C[Implementation] C --> D[Auto Tests] D --> E[Code Review] E --> F[Deployment] F --> G[Monitoring]

Implementation:

// Cursor workflow automation
const workflow = {
trigger: 'jira:ticket:assigned',
steps: [
{
action: 'cursor:agent',
prompt: 'Create implementation plan from ticket description',
},
{
action: 'cursor:agent',
prompt: 'Implement the feature following the plan',
},
{
action: 'cursor:agent',
prompt: 'Write comprehensive tests',
},
{
action: 'git:create-pr',
reviewers: ['ai-bot', 'team-lead'],
},
],
};

Integrate security tools with Cursor:

// Security-focused MCP integration
"Scan the codebase for security issues:
@security-mcp run SAST scan on @src
@dependency-mcp check for vulnerable packages
@secrets-mcp scan for exposed credentials"
// Remediation workflow
"For each security issue found:
1. Assess severity and exploitability
2. Generate fix following OWASP guidelines
3. Add tests to prevent regression
4. Document in security log"

Ensure regulatory compliance:

GDPR Compliance

"Audit data handling for GDPR:
- Find all personal data processing
- Verify consent mechanisms
- Check data retention policies
- Generate compliance report"

Accessibility

"WCAG 2.1 AA compliance check:
- Scan all UI components
- Fix color contrast issues
- Add missing ARIA labels
- Generate accessibility report"

Build AI-enhanced documentation:

// Generate comprehensive knowledge base
"Create a knowledge graph of our system:
1. Map all services and their relationships
2. Document data flows between components
3. Identify integration points
4. Create interactive visualization
5. Generate markdown documentation"
// Auto-update documentation
"Daily task:
- Detect code changes since last run
- Update affected documentation
- Flag outdated examples
- Generate changelog"
{
"cursor.telemetry.custom": {
"trackProductivity": true,
"metrics": ["linesOfCodeGenerated", "refactoringTime", "bugFixTime", "testCoverage"],
"reportInterval": "weekly"
}
}

Track the impact of AI assistance:

// Productivity metrics
const metrics = {
beforeCursor: {
featuresPerWeek: 2,
bugsPerFeature: 3,
hoursPerFeature: 20,
},
withCursor: {
featuresPerWeek: 5,
bugsPerFeature: 1,
hoursPerFeature: 8,
},
improvement: {
productivity: '150%',
quality: '66% fewer bugs',
timeReduction: '60%',
},
};

File Save Automation:

  1. Use VS Code’s built-in tasks system with Cursor
  2. Configure .vscode/tasks.json for automatic test runs:
.vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Run tests on save",
"type": "shell",
"command": "npm test ${file}",
"runOptions": {
"runOn": "folderOpen"
},
"problemMatcher": ["$tsc"]
}
]
}

PR Review Workflow:

  1. Open PR diff in Cursor
  2. Use Agent mode (Ctrl+I) with prompts like:
    • “Review @Files for breaking changes”
    • “Check @Recent Changes against our API contract”
    • “Analyze @Git commits for security issues”
  3. Use @Docs to reference team guidelines during review

You’ve mastered advanced Cursor techniques. Complete your journey with Team Collaboration tips to scale these practices across your entire development team.