AR

architecture-audit

Checks code against architectural standards and ADRs. Prevents illegal entity creation and scope violations.

Install

mkdir -p .claude/skills/architecture-audit && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/12061" && unzip -o skill.zip -d .claude/skills/architecture-audit && rm skill.zip

Installs to .claude/skills/architecture-audit

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Check codebase for architectural violations (factory bypass, raw assign, scope compliance, service layer). TRIGGER when the user discusses creating Core Data objects in production code, adding new entity creation sites, or before PR creation on milestones that touch the service/model layer.
291 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Detect direct creation of HouseholdScoped entities
  • Identify raw `assign` calls outside `ManagedObjectFactory.swift`
  • Check for missing `householdKey` predicates in fetch requests
  • Scan for `context.save()` calls in production view files
  • Report architectural violations with file and line references

How it works

The skill uses `grep` commands to scan Swift files for specific code patterns that indicate architectural violations, such as direct object creation or unauthorized context saves.

Inputs & outputs

You give it
Swift codebase files
You get back
List of architectural violations with file:line references

When to use architecture-audit

  • Run before submitting a pull request to the model layer
  • Validate factory patterns during code review
  • Scan for raw context assignments
  • Verify adherence to ADR 013 scope compliance

About this skill

Architecture Audit

Run this audit before any milestone that creates Core Data objects, during code review, and as a quality gate.

Checks

1. Factory Bypass Detection (ADR 014)

Search for direct creation of HouseholdScoped entities outside exempt files:

# Search for direct Entity(context:) for HouseholdScoped types
grep -rn 'WeeklyList(context:\|Recipe(context:\|PlannedMeal(context:\|MealPlan(context:\|Category(context:\|IngredientTemplate(context:' \
  --include='*.swift' \
  --exclude-dir=foragerTests \
  --exclude-dir=foragerUITests \
  --exclude='*Preview*' \
  --exclude='DefaultSeeder.swift' \
  --exclude='SampleDataSeeder.swift' \
  --exclude='ManagedObjectFactory.swift' \
  --exclude='HouseholdService.swift'

Expected: Zero matches in non-exempt production files. Exempt files: Tests, previews, seeders, HouseholdService (migration), ManagedObjectFactory itself. Note: Repository files may have fallback paths with direct creation — these are acceptable IF they also have factory-first branches.

2. Raw Assign Detection

Search for viewContext.assign( or context.assign( outside ManagedObjectFactory.swift:

grep -rn 'viewContext\.assign(\|context\.assign(' --include='*.swift' --exclude='ManagedObjectFactory.swift'

Expected: Zero matches.

3. ADR 013 Scope Compliance (services + repositories only)

Search for HouseholdScoped fetch requests missing householdKey predicate in the service + repository layers:

# Look for fetch requests on HouseholdScoped entities in Services/ and Repositories/ ONLY
grep -rn 'NSFetchRequest<WeeklyList>\|NSFetchRequest<Recipe>\|NSFetchRequest<MealPlan>\|NSFetchRequest<PlannedMeal>\|NSFetchRequest<Category>\|NSFetchRequest<IngredientTemplate>\|NSFetchRequest<GroceryListItem>\|NSFetchRequest<Ingredient>\|NSFetchRequest<Store>' \
  Services/ forager/Repositories/ \
  --include='*.swift'

Then verify each fetch includes a householdKey predicate (grep the same file within ~10 lines after the declaration for the string householdKey).

Non-goal — view-layer @FetchRequest: this check intentionally does NOT scan forager/Views/. The view-layer in-memory-filter pattern is emergent (first appeared f263730 on 2026-01-18; spread by copy-paste across 24 views; not formalized by any ADR) and is deferred to a future change named decide-view-layer-scope-architecture which will evaluate alternatives, pilot one, migrate all ~43 sites, and only then write a definitive ADR. Do NOT extend this check to forager/Views/ before that future change lands — the bare @FetchRequest on a HouseholdScoped entity is NOT a violation of ADR 013 today. See the auto-memory entry project_scope_safety_three_layers.md for context.

4. Service Layer Compliance

Search for context.save() in production view files (views should use services). Previews are exempt — #Preview { } blocks and PreviewProvider extensions are a legitimate standalone environment that may call context.save() to stage preview data.

# Production view saves: exclude dedicated preview files via glob
grep -rn 'context\.save()\|viewContext\.save()' forager/Views/ \
  --include='*.swift' \
  --exclude='*Preview*'

Manual follow-up: matches inside #Preview { ... } macro blocks or PreviewProvider extension bodies (in files NOT named *Preview*) are also legitimate. Discount them when reporting violations. For each reported match, open the file and confirm it is outside any #Preview { } block and outside any PreviewProvider extension before flagging it.

Expected: Zero production matches (all production saves through service layer).

How to Run

Use the Grep tool to execute each check. Report violations with file:line references.

When to Run

  • Before starting any milestone that creates Core Data objects
  • During code review / PR creation
  • After completing service or view layer changes
  • As a quality gate before marking milestone complete

When not to use it

  • When scanning test files, previews, or seeders for factory bypasses
  • When scanning `ManagedObjectFactory.swift` for raw assign calls
  • When scanning view-layer `@FetchRequest` for `householdKey` predicates

Limitations

  • Exempt files for factory bypass detection include tests, previews, seeders, and specific service files
  • Raw assign detection excludes `ManagedObjectFactory.swift`
  • Scope compliance check intentionally does NOT scan `forager/Views/`

How it compares

This skill enforces specific architectural rules by programmatically scanning the codebase for predefined patterns, providing an automated audit compared to manual code review.

Compared to similar skills

architecture-audit side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
architecture-audit (this skill)03moReviewIntermediate
swift-concurrency-expert45moNo flagsAdvanced
ios-dev-guidelines36moNo flagsBeginner
implement-feature17moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

swift-concurrency-expert

Dimillian

Swift Concurrency review and remediation for Swift 6.2+. Use when asked to review Swift Concurrency usage, improve concurrency compliance, or fix Swift concurrency compiler errors in a feature or file.

420

ios-dev-guidelines

anyproto

Context-aware routing to Swift/iOS development patterns, architecture, and best practices. Use when working with .swift files, ViewModels, Coordinators, refactoring, or discussing Swift/SwiftUI patterns.

37

implement-feature

tddworks

Guide for implementing features in ClaudeBar following architecture-first design, TDD, rich domain models, and Swift 6.2 patterns. Use this skill when: (1) Adding new functionality to the app (2) Creating domain models that follow user's mental model (3) Building SwiftUI views that consume domain models directly (4) User asks "how do I implement X" or "add feature Y" (5) Implementing any feature that spans Domain, Infrastructure, and App layers

16

swiftui-performance-developer

anyproto

Audit and improve SwiftUI runtime performance through code review and Instruments guidance. Use for diagnosing slow rendering, janky scrolling, excessive view updates, or layout thrash in SwiftUI apps.

16

tests-developer

anyproto

Smart router to testing patterns and practices. Use when writing unit tests, creating mocks, testing edge cases, or working with Swift Testing and XCTest frameworks.

16

feature-toggle-developer

anyproto

Guides systematic removal of feature toggles from the codebase with automated cleanup detection. Use when removing feature flags, enabling toggles permanently, or cleaning up unused code after toggle removal.

14

Search skills

Search the agent skills registry