agentleFS
AzureADAzureAD/microsoft-authentication-library-for-objc/.cursor/rules/ruler_cursor_instructions.mdc

microsoft-authentication-library-for-objc / rules

Cursor rule347 starsChanged 12 months agoMITView on GitHub

This is the Microsoft Authentication Library (MSAL) for iOS and macOS - an authentication SDK for integrating Microsoft identity platform authentication into native Apple applications. The library supports OAuth2/OpenID Connect protocols for Microsoft Entra ID (workforce), External ID (customers), Azure AD B2C, and personal Microsoft accounts. Public headers MUST be in: Unit Tests: Located in MSAL/test/unit/ Integration Tests: Located in MSAL/test/integration/ Automation Tests: Located in MSAL/test/automation/ (requires conf.json - not in repo) Running Tests: READ: .clinerules/04-Code-style-guidelines.md - Contains mandatory Objective-C…

We split this ruler_cursor_instructions.mdc into the rules it gives an agent

17 rules. About 0 are common, 9 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Error handling: Check return value, NEVER the error variable directly

    line 78
  2. Very specific:

    Properties over ivars: Use @property declarations

    line 80
  3. Very specific:

    Add header to appropriate MSAL/src/public/ subdirectory

    line 105
  4. Very specific:

    Import in MSAL/src/public/MSAL.h umbrella header

    line 106
  5. Very specific:

    Update MSAL.podspec if needed (public_header_files)

    line 107
  6. Very specific:

    Add to MSAL/module.modulemap if using native auth subspec

    line 108
  7. Distinctive:

    Document in header comments (Jazzy-compatible)

    line 109
  8. Distinctive:

    Test both Debug and Release configurations

    line 115
  9. Distinctive:

    Internal: Avoid. This library should be self-contained.

    line 119
  10. Very specific:

    Update submodule reference: cd MSAL/IdentityCore && git checkout <commit>

    line 125
  11. Distinctive:

    Commit submodule update in MSAL repo

    line 126
  12. Distinctive:

    Test thoroughly - affects BOTH MSAL and ADAL

    line 127
  13. Distinctive:

    Only search for additional information if:

    line 142
  14. Very specific:

    Check .clinerules/*.md for code style specifics, API usage, configuration steps and feature flag guidance.

    line 151
  15. Distinctive:

    Check README.md for user-facing documentation

    line 152
  16. Very specific:

    Check CHANGELOG.md for version history and breaking changes

    line 153
  17. Distinctive:

    Check specific xcconfig files for build settings

    line 154

≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
ruler_cursor_instructions.mdc
# Cursor Instructions for MSAL iOS/macOS

## Repository Overview

This is the **Microsoft Authentication Library (MSAL) for iOS and macOS** - an authentication SDK for integrating Microsoft identity platform authentication into native Apple applications. The library supports OAuth2/OpenID Connect protocols for Microsoft Entra ID (workforce), External ID (customers), Azure AD B2C, and personal Microsoft accounts.

**Key Facts:**

- **Languages:** Objective-C (primary), Swift (native auth APIs)
- **Platforms:** iOS 16+, macOS 11+, visionOS 1.2+
- **Distribution:** CocoaPods, Carthage, Swift Package Manager, Git submodule
- **Submodule:** `MSAL/IdentityCore` contains shared common code (do NOT make direct changes without understanding impact)

## Critical: Architecture & Project Structure

### Main Workspace & Targets

- **Workspace:** `MSAL.xcworkspace` (ALWAYS use .xcworkspace, NEVER .xcodeproj directly)
- **Main Project:** `MSAL/MSAL.xcodeproj`
- **Submodule:** `MSAL/IdentityCore` - shared common library (git submodule)

### Source Code Organization

```
MSAL/src/
├── public/              # Public API headers (MSAL prefix)
│   ├── MSAL.h          # Main umbrella header
│   ├── ios/            # iOS-specific public headers
│   ├── mac/            # macOS-specific public headers
│   ├── configuration/  # Configuration classes
│   └── native_auth/public/  # Native auth public APIs (Swift)
├── MSALPublicClientApplication.m  # Main SDK entry point
├── configuration/      # Internal configuration
├── instance/          # Authority/instance handling
├── native_auth/       # Native authentication (Swift + Obj-C bridge)
├── telemetry/         # Telemetry implementation
└── util/              # Utilities
```

### Public API Files

Public headers MUST be in:

- `MSAL/src/public/*.h` (shared)
- `MSAL/src/public/ios/*.h` (iOS only)
- `MSAL/src/public/mac/*.h` (macOS only)
- `MSAL/src/public/configuration/*.h` (config classes)
- `MSAL/src/native_auth/public/` (native auth - Swift)

### Configuration Files

- **Build configs:** `MSAL/xcconfig/*.xcconfig` - Xcode build settings
- **Swift lint:** `MSAL/.swiftlint.yml` - only applies to `src/native_auth`
- **CocoaPods:** `MSAL.podspec` - pod spec with `app-lib` and `native-auth` subspecs
- **Swift PM:** `Package.swift` - binary framework distribution
- **Privacy:** `MSAL/PrivacyInfo.xcprivacy` - Apple privacy manifest

## Testing

**Unit Tests:** Located in `MSAL/test/unit/`
**Integration Tests:** Located in `MSAL/test/integration/`
**Automation Tests:** Located in `MSAL/test/automation/` (requires conf.json - not in repo)

**Running Tests:**

- Via Xcode: Select scheme and Cmd+U
- E2E tests require test configuration from Azure KeyVault (CI only)

## Code Style Guidelines

**READ:** `.clinerules/04-Code-style-guidelines.md` - Contains mandatory Objective-C style rules

**Key Rules (Repository-Specific):**

1. **Opening braces on NEW line** (differs from most Obj-C guides)
2. **4-space indentation** (never tabs)
3. **Imports NOT grouped** - list without organizing comments
4. **Error handling:** Check return value, NEVER the error variable directly
5. **Prefixes:** `MSAL` for public classes, `MSID` for IdentityCore internal
6. **Properties over ivars:** Use `@property` declarations
7. **Swift lint:** Native auth code must pass SwiftLint (line length: 150)

**Example:**

```objc
- (BOOL)performOperationWithError:(NSError **)error
{
    NSError *internalError = nil;
    BOOL result = [self doSomethingWithError:&internalError];
    
    if (!result)  // Check return value, not error
    {
        if (error) *error = internalError;
        return NO;
    }
    
    return YES;
}
```

## Making Changes

### Adding New Public API

1. Add header to appropriate `MSAL/src/public/` subdirectory
2. Import in `MSAL/src/public/MSAL.h` umbrella header
3. Update `MSAL.podspec` if needed (public_header_files)
4. Add to `MSAL/module.modulemap` if using native auth subspec
5. Document in header comments (Jazzy-compatible)

### Modifying Build Settings

1. Edit appropriate `.xcconfig` file in `MSAL/xcconfig/`
2. Settings cascade: specific → platform → common
3. Test both Debug and Release configurations

### Adding Dependencies

**Internal:** Avoid. This library should be self-contained.
**External (IdentityCore):** Coordinate with common library team.

### Modifying IdentityCore Submodule

1. Make changes in IdentityCore repo separately
2. Update submodule reference: `cd MSAL/IdentityCore && git checkout <commit>`
3. Commit submodule update in MSAL repo
4. Test thoroughly - affects BOTH MSAL and ADAL

## Key Files to Never Modify

- `MSAL/IdentityCore/` - managed as submodule
- `Package.swift` - auto-generated by release process
- `MSAL.zip` - binary distribution artifact
- `build/` - build artifacts directory
- `.xcuserdata/` - user-specific Xcode settings

## Trust These Instructions

These instructions have been validated against the actual build system, CI pipelines, and codebase structure. If you encounter conflicts between these instructions and other information:

1. **Trust these instructions FIRST**
2. Only search for additional information if:
   - Instructions are incomplete for your specific task
   - You encounter an error not covered here
   - You need API usage examples (see `.clinerules/03-MSAL-API-usage.md` for MSAL API samples)
   - You need to create a new application with MSAL authentication (see `.clinerules/AGENTS.md` for details about the different options the user can select)
   - You are implementing a new feature in MSAL library, it needs to be guarded by a feature flag (see `.clinerules/05-feature-gating.md` for guidelines)

**When searching:**

- Check `.clinerules/*.md` for code style specifics, API usage, configuration steps and feature flag guidance.
- Check `README.md` for user-facing documentation
- Check `CHANGELOG.md` for version history and breaking changes
- Check specific xcconfig files for build settings

Download now (ZIP)

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 3,978 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository4 other files it gives its agents.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.