https://github.com/ericodx/swift-marshal
Ensure consistent member ordering in Swift types to improve readability and maintainability.
https://github.com/ericodx/swift-marshal
cli swift swift-package-manager xcode-plugin
Last synced: about 1 month ago
JSON representation
Ensure consistent member ordering in Swift types to improve readability and maintainability.
- Host: GitHub
- URL: https://github.com/ericodx/swift-marshal
- Owner: ericodx
- License: mit
- Created: 2026-03-15T15:23:12.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2026-03-30T13:37:56.000Z (about 1 month ago)
- Last Synced: 2026-03-30T15:25:50.357Z (about 1 month ago)
- Topics: cli, swift, swift-package-manager, xcode-plugin
- Language: Swift
- Homepage: https://github.com/ericodx/swift-marshal
- Size: 1020 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: .github/SECURITY.md
- Governance: Docs/GOVERNANCE.md
Awesome Lists containing this project
README
# Swift Marshal
[](https://swiftpackageindex.com/ericodx/swift-marshal)
[](https://swiftpackageindex.com/ericodx/swift-marshal)
[](https://github.com/ericodx/swift-marshal/actions)
[](https://sonarcloud.io/summary/new_code?id=deploy-on-friday-swift-marshal)
[](https://sonarcloud.io/summary/new_code?id=deploy-on-friday-swift-marshal)
**Ensure consistent member ordering in Swift types to improve readability and maintainability.**
`swift-marshal` is an AST-based CLI that ensures consistent member ordering within Swift type declarations. It reports violations with `check` and applies fixes with `fix`, driven by SwiftSyntax and a declarative configuration file.
## Why
Inconsistent member ordering increases:
- cognitive load when navigating code
- friction during code reviews
- inconsistency across teams and codebases
`swift-marshal` helps maintain a predictable structure, making code easier to read, review, and maintain.
## Features
- Ensures consistent member ordering using AST-based analysis
- Preserves original logic and formatting
- Supports automated fixes via CLI
- Can be integrated into CI pipelines
- Configurable through a declarative YAML file
## Install
```bash
brew tap ericodx/homebrew-tools
brew install swift-marshal
```
Other installation methods — pre-built binary, build from source, pre-commit hook, Xcode plugin — are covered in the [Installation Guide](Docs/INSTALLATION.md).
## Quick start
```bash
# Generate a config file (auto-detects your source directories)
swift-marshal init
# Check for violations
swift-marshal check
# Apply fixes
swift-marshal fix
```
Example output:
```
Sources/App/Models/User.swift:
struct User (line 3)
[needs reordering]
original:
- instance_method fullName
- instance_property firstName
- initializer init
reordered:
- initializer init
- instance_property firstName
- instance_method fullName
✗ 1 type in 1 file needs reordering
Run 'swift-marshal fix' to apply changes
```
## Configuration
Drop a `.swift-marshal.yaml` in the project root to control member order, paths, and extension handling:
```yaml
version: 1
ordering:
members:
- typealias
- associatedtype
- initializer
- type_property
- instance_property
- subtype
- type_method
- instance_method
- subscript
- deinitializer
extensions:
strategy: separate
respect_boundaries: true
paths:
- Sources/
```
Full reference in the [Usage & Configuration Guide](Docs/USAGE.md).
## Documentation
| Document | Description |
|---|---|
| [Installation](Docs/INSTALLATION.md) | Homebrew, binary, source, pre-commit hook, Xcode plugin |
| [Usage & Configuration](Docs/USAGE.md) | CLI options, YAML config, output formats, CI integration |
| [Architecture](Docs/Architecture/README.md) | Module map, pipeline design, configuration model, AST rewriting |
| [Codebase Reference](Docs/CodeBase/README.md) | Every type, protocol, and stage documented |