macOS CLI tool for Swift codebase intelligence β find critical files, generate dependency graphs, detect traffic patterns, learning paths.
Built 100% in Swift. Fully offline. No network required. No telemetry. No accounts.
AI-powered features (natural-language Q&A) are available as a separate opt-in β see AI Integration (Opt-In).
cd ArchSwiftScope
# Projects under 300K lines β just run directly
swift run codecontext analyze ~/path/to/your/project --open
# Large projects (300K+ lines) β release build is 5β10Γ faster
swift build -c release
.build/release/codecontext analyze ~/path/to/your/project --open- Summary β total files, lines of code, declarations by type (structs, classes, enums, protocols, actors), Swift version, deployment targets, app version, and package count
- ποΈ Architecture β structural decomposition across 8 sub-sections:
- π¨ Arch Pattern β MV, MVVV, VIPER, RIBs and other
- π Layers β files classified by directory/naming patterns into UI/Views, Presentation, Models, API/Networking, Persistence, Auth, Config, Utilities, Tests, Core β with file counts, line counts, and proportional bar chart
- π§© Components β detected architectural components from Apple framework imports (SwiftUI, UIKit, CoreData, Combine, ARKit, CoreML, and 30+ more)
- π Apple Frameworks β all Apple SDK frameworks used, as a searchable tag cloud
- π¦ External Libraries β third-party package imports detected across the codebase
- π Local Packages β Swift Package Manager modules with file counts, line counts, build-system badges (SwiftUI/UIKit/AppKit), Metal shader indicators, and clickable navigation links
- πΊοΈ Architecture Graph β top-level inter-package dependency graph
- π¨ Design Patterns β detected GoF and architectural patterns (Singleton, Factory, Observer, Coordinator, and more) grouped by category with occurrence counts and example file links
- 𧬠OOP vs POP β style signal across all Swift types, scored across three weighted categories:
- Protocol Design (55%) β protocol density, constrained generics, conformance breadth (Impl-pattern detection), default implementations,
associatedtypeusage,some-with-user-protocols, andA & Bcomposition - Value Semantics (30%) β struct-to-class ratio,
finalkeyword usage, enums with associated values - Anti-inheritance (15%) β average inheritance depth,
overridedensity, NSObject subclass count - Overall POP score (0β100%) shown on a gradient bar; each metric scored 0β100% with POP / Mixed / OOP signal tags
- Protocol Design (55%) β protocol density, constrained generics, conformance breadth (Impl-pattern detection), default implementations,
- π Traffic β inbound and outbound connection signals detected across all source files (shown only when signals are present):
- π₯ Inbound β Vapor/server-side Swift route definitions (
app.get,routes.post, β¦) and TCP server declarations (NWListener) - π€ Outbound β HTTP/HTTPS/WebSocket URL string literals; TCP connections via
NWConnection(Network.framework),NWPathMonitor(reachability),SCNetworkReachabilityCreateWithName(SystemConfiguration), BSD POSIXsocket(β¦SOCK_STREAMβ¦), andCFStreamCreatePairWithSocketToHost(Core Foundation) - Each entry shows a protocol tag (REST Β· WebSocket Β· gRPC Β· GraphQL Β· TCP), URI or detected pattern, data format (JSON / Protobuf / XML), and a clickable VS Code link to the source file and line
- π₯ Inbound β Vapor/server-side Swift route definitions (
5.π¨ Security Risks - (63 active checks Β· index 0β1000) Higher index = more risk. DANGER INDEX aggregates 14 weighted categories; each category's risk scales with violation density. Per-category weight bars and clickable VS Code links to every violation. Categories without active checks are shown as not assessed.
- π Git Analysis β full git history intelligence across 6 sub-sections:
- π₯ Team Contribution Map β developer activity with files modified, commit counts, first/last change dates, and top-3 modules per author
- πΏ Branch Management β total branch count (local + remote), avg branch lifetime, time-to-merge, integration delay, rollback rate, peak commit day, stale branches (>90 days inactive), and already-merged branches
- π Branching Model β role-based classifier that detects Gitflow, Trunk-Based Development, GitHub Flow, GitLab Flow, and OneFlow from the
.gitcommit DAG. Scores all five models against the same evidence and displays ranked confidence bars. - π₯ Code Churn β top 15 most frequently changed files by commit count, ranked from highest to lowest
- π Semantic Standards β conventional commit compliance rate, semver tag count, and a breakdown of commit prefix types (feat, fix, chore, etc.)
- π₯ Hot Zones β files with the highest PageRank scores, identifying the most connected and architecturally significant code
- π Longest Functions β ranked list of functions by line count, with clickable VS Code links jumping directly to the function definition
- π Module Insights β package penetration (which modules are foundational dependencies), plus TODO/FIXME density per module
- π¦ Packages & Modules β per-package breakdown with file inventory, declaration statistics, interactive force-directed dependency graph (colored by type), and inline documentation previews
- π¨ Assets (shown when
.xcassetsare present) β media resource analysis: total bundle size in MB, file count and size breakdown by type (image, audio, video), and top-3 heaviest files per category with individual file sizes
Every core feature runs entirely on your machine:
- Source parsing β Apple's native SwiftSyntax, no external services
- Dependency graphs & PageRank β computed locally
- Git history analysis β reads your local
.gitdirectory - HTML report generation β self-contained, no CDN links, no external assets
- Caching β actor-based file cache stored on disk
Your code never leaves your machine unless you explicitly enable the optional AI integration and send a query.
cd ArchSwiftScope
# Debug build (fast compilation)
swift build
# Run directly
swift run codecontext analyze ~/Projects/MyApp
# Release build (optimized, ~3Γ faster runtime)
swift build -c release
# The binary is at:
.build/release/codecontextswift build -c release
sudo cp .build/release/codecontext /usr/local/bin/
# Now use from anywhere:
codecontext analyze ~/Projects/MyApp
codecontext evolution --months 12swift build -c release && sudo cp .build/release/codecontext /usr/local/bin/ && echo "β
installed"open Package.swiftIn Xcode:
- Select the
codecontextscheme - Edit Scheme β Run β Arguments β add:
analyze /path/to/your/project - βR to build and run
# Analyze current directory
codecontext analyze
# Analyze specific path
codecontext analyze ~/Projects/MyApp
# With options
codecontext analyze ~/Projects/MyApp --no-cache --verbose --open
# Skip the Packages & Modules section (faster for large codebases)
codecontext analyze ~/Projects/MyApp --skip-modules --open
# Enable GitHub link toggling in the report
codecontext analyze ~/Projects/MyApp --github-links https://github.com/owner/repo --openPass the root URL of your GitHub repository to unlock a VS Code / GitHub toggle in the report's Links card.
codecontext analyze ~/Projects/MyApp \
--github-links https://github.com/owner/MyApp \
--openWhen GitHub mode is active every file link in the report opens the corresponding file directly on GitHub (at the correct line) instead of in VS Code. The selected mode persists across page reloads via localStorage.
| Mode | Link format |
|---|---|
| VS Code (default) | vscode://file//abs/path/to/File.swift:42 |
| GitHub | https://github.com/owner/repo/blob/main/relative/path/File.swift#L42 |
The branch name is taken from the current git branch at analysis time. No GitHub authentication is required β links point to the public (or private, if you're signed in) repository URL you supply.
# Default: 6 months back, 30-day intervals
codecontext evolution
# Custom range
codecontext evolution --months 12 --interval 7codecontext init
# Creates .codecontext.json with sensible defaultsCreate .codecontext.json in your project root (or run codecontext init):
{
"excludePaths": [".git", ".build", "DerivedData", "Pods", "Carthage"],
"maxFilesAnalyze": 5000,
"gitCommitLimit": 1000,
"enableCache": true,
"enableParallel": true,
"hotspotCount": 15,
"fileExtensions": ["swift"]
}All options above are offline. No network configuration needed.
This is entirely optional. Every feature described above works without it.
If you want to ask natural-language questions about your codebase, you can enable the AI module. This sends a context summary to an external LLM provider, so review your provider's data policies before enabling.
Add an ai block to your .codecontext.json:
{
"ai": {
"enabled": false,
"provider": "anthropic",
"apiKey": "",
"model": "claude-sonnet-4-20250514"
}
}| Provider | provider |
Model examples |
|---|---|---|
| Anthropic Claude | "anthropic" |
claude-sonnet-4-20250514 |
| Google Gemini | "gemini" |
gemini-2.5-flash |
codecontext ask "Where is the authentication logic?"
codecontext ask "What would break if I refactored UserService?"When you run ask, a summary of your project structure and relevant code context is sent to the configured provider. Raw source files are not uploaded in full β the tool assembles a focused context window. No data is sent for any other command (analyze, evolution, init).
ArchSwiftScope/
βββ Package.swift
βββ Sources/CodeContext/
β βββ CLI/
β β βββ CodeContextCLI.swift # @main entry point
β β βββ AnalyzeCommand.swift # Main analysis command
β β βββ AskCommand.swift # AI Q&A command (opt-in)
β β βββ EvolutionCommand.swift # Temporal analysis
β β βββ InitCommand.swift # Config initialization
β βββ Core/
β β βββ AnalysisPipeline.swift # Orchestrates all analysis passes
β β βββ ArchAnalyzer.swift # Architecture pattern + layer classifier
β β βββ DesignPatternDetector.swift # GoF / architectural pattern detection
β β βββ OOPvsPOPAnalyzer.swift # OOP vs POP scoring
β β βββ SecurityAnalyzer.swift # 55-check security index (0β1000)
β β βββ MonkeyPatchedLibs.swift # Vendored C/C++ library detection
β β βββ Config/
β β β βββ CodeContextConfig.swift # Config models + loader
β β βββ Cache/
β β β βββ CacheManager.swift # Actor-based file cache
β β βββ Parser/
β β β βββ ParsedFile.swift # File model + git metadata
β β β βββ SwiftParser.swift # Swift source parser
β β β βββ ObjCParser.swift # Objective-C header parser
β β β βββ ParserFactory.swift # Extension β parser dispatch
β β β βββ ParallelParser.swift # Concurrent parsing with cache
β β βββ Scanner/
β β β βββ RepositoryScanner.swift # Directory walker + exclusion rules
β β β βββ GitAnalyzer.swift # Git history, branch stats,
β β β # and branching model detection
β β β # (Gitflow / TBD / GitHub Flow /
β β β # GitLab Flow / OneFlow)
β β βββ Graph/
β β β βββ DependencyGraph.swift # Dependency graph + PageRank
β β βββ Generator/
β β β βββ LearningPathGenerator.swift
β β βββ Temporal/
β β β βββ TemporalAnalyzer.swift # Codebase evolution tracking
β β βββ AI/
β β β βββ AICodeAnalyzer.swift # URLSession AI client (opt-in)
β β βββ Exceptions/
β β βββ CodeContextError.swift
β βββ Output/
β βββ ReportGenerator.swift # Self-contained HTML report
βββ Tests/CodeContextTests/
βββ CodeContextTests.swift
swift test- macOS 13+ (Ventura or later)
- Xcode 15+ / Swift 5.9+
- git (comes with Xcode Command Line Tools)
- No internet connection required for core features