agentleFS
AzureADAzureAD/microsoft-authentication-library-for-objc/CLAUDE.md

microsoft-authentication-library-for-objc

CLAUDE.md347 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: In interactive sessions on a developer's…

We split this CLAUDE.md into the rules it gives an agent

18 rules. About 0 are common, 10 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    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 84
  2. Very specific:

    Properties over ivars: Use @property declarations

    line 86
  3. Distinctive:

    Comments: Only comment non-obvious rationale.

    line 88
  4. Very specific:

    Add header to appropriate MSAL/src/public/ subdirectory

    line 112
  5. Very specific:

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

    line 113
  6. Very specific:

    Update MSAL.podspec if needed (public_header_files)

    line 114
  7. Very specific:

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

    line 115
  8. Distinctive:

    Document in header comments (Jazzy-compatible)

    line 116
  9. Distinctive:

    Test both Debug and Release configurations

    line 122
  10. Distinctive:

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

    line 126
  11. Very specific:

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

    line 132
  12. Distinctive:

    Commit submodule update in MSAL repo

    line 133
  13. Distinctive:

    Test thoroughly - affects BOTH MSAL and ADAL

    line 134
  14. Distinctive:

    Only search for additional information if:

    line 149
  15. Very specific:

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

    line 158
  16. Distinctive:

    Check README.md for user-facing documentation

    line 159
  17. Very specific:

    Check CHANGELOG.md for version history and breaking changes

    line 160
  18. Distinctive:

    Check specific xcconfig files for build settings

    line 161

≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md 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
CLAUDE.md

Claude 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)

AI Agent Build Safety

In interactive sessions on a developer's Mac, AI agents MUST NOT invoke build.py, xcodebuild, simctl, or any command that starts an Xcode build, test, or simulator. Ask the user to run the relevant scheme from MSAL.xcworkspace in Xcode and report the result instead.

If the user explicitly requests a local CLI command instead of using Xcode, require exactly one build.py --targets <target> value and prefer --no-clean for incremental validation. Never suggest bare ./build.py, multiple targets, concurrent/background builds, or ad-hoc xcodebuild commands for a developer's Mac. CI may continue using its repository-defined full validation matrix.

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)
  8. Comments: Only comment non-obvious rationale. Don't add comments that explain what the code already explains.

Example:

- (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)

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.