Home Articles

How to Use .cursorignore, .cursor/rules, and @Docs Effectively in Cursor

Cursor IDE is an innovative code editor helps to enhance developer productivity. Built with AI integration - Large Language Models.

Key Features

  • Agent

  • Chat

  • Tab Completion

Cursor IDE’s Smart Context

Cursor IDE’s Smart Context

Managing Context in Cursor IDE

Cursor IDE provides powerful mechanism to include or exclude files from AI context and to define custom AI behaviour.

  • project rule files in .cursor/rules/ for persistent AI instructions

  • @Docs system for integrating documentation into AI assistance

  • .cursorignore file for ignoring certain files

Cursor Rules

Act as an extension to AI’s system prompt, ensuring the model consistently follows code convention or workflows.

Rules are reusable, scoped instructions

“persistent way to encode context, preferences, or workflows for your projects”

Support three different types of rules:

  • Project Rules - Stored in .cursor/rules

  • User Rules - Global to your Cursor environment.

  • .cursorrules (Legacy) - Supported but deprecated

Where to Rules live

Project rules are simply files (with a .mdc extension) stored under a .cursor/rules/ directory in your repository

How Rules work

Large Language Models (LLM) don’t retain the conversation memory between completions or sessions but rules that really helpful in bridging that gap by injecting specified text into the prompt every time.

Rule to the model’s context is often considered to high priority system instruction once activated.

Apply in all AI Models (both chat and editor completions)

Rules Types

  • Always Rules - Always included in model’s context for every prompt in the project.

  • Auto-Attached Rules - These rules apply automatically when certain files or paths are relevant, based on glob patterns

  • Agent-Requested Rules - These rules are available to the AI model to include if it believes they’re relevant, rather like optional guidelines. You must provide a description for such rules

  • Manual Rules - These are only included when you explicitly invoke them. To use a manual rule, you can mention it in a chat prompt via the @Cursor Rules menu or by typing @

Rules File Structure (.mdc files)

Rules are .mdc files inside .cursor/rules/ that inject persistent instructions into AI’s model context.

For iOS Devs:

SwiftUI cursor rules

SwiftUI cursor rules

Now, whenever you ask for a SwiftUI view, the AI will generate code consistent with your architecture.

description gives a human-readable summary

globs specifies that this rule auto-applies for any files under a services/ directory with a .ts extension.

alwaysApply is said to be true indicates the rule would be included universally, and the globs could be omitted whereas false indicates it’s not a global “always on” rule.

Use cases:

  • Enforces the AI’s suggestions to adhere those tools, patterns and coding standards

  • Can suggest the AI to use the template when creating the service

  • Automate the workflow

  • Project Knowledge Base


@Docs

Cursor lets you embed docs directly into your prompts using @Docs.

How iOS Devs make use @Docs:

  • Add reference Apple docs:

  • Add your own team wikis such as network layer guides or Network Framework

  • Load third-party SDKs like Firebase or RevenueCat to answer usage questions inline

This is how you can add Docs to Cursor: Settings > Features > Docs

Adding Documentation link to Cursor Docs

Adding Documentation link to Cursor Docs

Let’s see how to use @Docs:

Use Cmd + L to open the Cursor Chat

Example Usage: How to fetch and decode data with async-await? @Modern Swift Concurrency

@Docs example

@Docs example


SPONSOR

iOS Conference AI Image

The Unique iOS Swift Conference in the UK

SwiftLeeds is a premier iOS conference taking place on October 7-8 this year. If you’re looking to stay updated on the latest trends in iOS development and connect with like-minded professionals, this event is a must-attend! Don’t miss out—book your tickets now!

Get your tickets!

.cursorignore

Xcode projects can get cluttered quickly—think Pods/, DerivedData/, .xcassets, build outputs, or .xcworkspace folders.

Use .cursorignore to:

  • Exclude generated files like *.xcarchive, *.ipa, build/, or .xcuserstate that don’t contribute to logic.

  • Keep secrets secure by ignoring .env, GoogleService-Info.plist, or Firebase config files.

  • Avoid unnecessary from large third party Swift packages

Global Cursor Ignore List - Example

Global Cursor Ignore List - Example

Navigate the following:

Cursor → Settings → VS Code Settings → Search for “Cursor ignore list”

Use cases

  • Security: Exclude files containing secrets or credentials

  • Hierarchical rules: By default, Cursor looks for one .cursorignore in the workspace root.

  • Team workflows: A best practice is to add .cursorignore to your repository’s .gitignore

  • AI focused on your source code and relevant docs

Workflow Example for Swift Developers

Here we have realistic example for an iOS Engineer using Cursor IDE:

🙋

I need a SwiftUI screen to show user product data from a REST API.

Let’s add this to our Cursor Chat

How to use Cursor Chat

How to use Cursor Chat

Below is the generated file information with respect to SwiftUI screen and API Service

Generated swift files

Generated swift files

  • AI uses .cursor/rules to follow your MVVM + async/await architecture.

  • AI skips xcworkspace, xcuserstate because they’re in .cursorignore.

  • Reference @Modern Swift Concurrency for network request syntax since it works well with SwiftUI.

Finally, the result: It gives you a clean UserProfileView with a UserProfileViewModel, async network call, and SwiftUI layout.

Final Thoughts

With .cursorignore, .cursor/rules, and @Docs, you’re not just getting AI help—you’re training it to act like your best teammate.

In the upcoming article, we will cover advance topics such as MCP i.e. Model Context Protocol.

This is a free third party commenting service we are using for you, which needs you to sign in to post a comment, but the good bit is you can stay anonymous while commenting.