AGENTS.md
AGENTS.mdAGENTS.mdroot
Quality
67/100
Scores the file, not the repository.Length
1,082 words
33 headings · 0 code blocksRepository
12k
— · pushed 4 days agoLast changed
2 days ago
First indexed 2 days ago.1# Project Guidelines23## Purpose & Scope45This file is the canonical source of project conventions for humans & agents.6Read it before making repository changes.78## Minimum Versions910- **Swift:** 6.311- **Xcode:** 26.412- **macOS:** 131314## Quick Entry Points1516- `Scripts/bootstrap`17- `Scripts/format`18- `Scripts/lint -AP` (quick) / `Scripts/lint` (includes unused code checks)19- `Scripts/build` (debug) / `Scripts/build '' -c release` (release)20- `Scripts/test`21- `Scripts/package`2223## Git Workflow2425- `main` is the trunk26- Branch topics from `main`27- Before committing (to preserve tokens, agents should skip steps 2 & 3):28 1. Add or edit tests for non-trivial changes29 2. Repeatedly run `Scripts/format` until no modifications are made30 3. Repeatedly run `Scripts/lint` & fix all violations until no violations are31 reported32- **Commit messages:** Follow [commit message conventions](33 https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html34 )35- Tag releases as `vX.Y.Z`3637## Content Formatting3839- **Newlines:** UNIX (i.e. `\n`)40- **Indentation:** Tabs (width: 2)41- **Max line length:** 120 characters (tabs count as 2 characters)42- **Unnecessary trailing whitespace:** Remove43- **File ends:** Single newline4445## Refactoring Rules4647Unless absolutely necessary for functionality or fixes, or unless violations of48standards are discovered, do not:4950- reformat51- rename52- reorder53- respace54- reword55- remove comments56- refactor if it worsens the caller interface5758Refactoring should:5960- Keep clean abstractions61- Inline a utility iff it is single-use62- Replace a utility iff the new version is more correct, performant, and/or63 simpler than the existing version, in descending order of priority6465## Scripting6667- Use zsh for scripts (except for shell-specific completion scripts)68- Zsh scripts must be compatible with all zsh versions starting with the version69 ([currently 5.9](https://opensource.apple.com/releases/)) bundled with the70 newest version ([currently 13.5.x](https://opensource.apple.com/releases/))71 of the oldest macOS major version supported by mas72 ([currently 13](Package.swift))73- Use `#!/bin/zsh` shebang (with `-Ndefgku` options, unless any changes to the74 options are absolutely necessary)75- Run `. "${0:A:h}/_setup_script"` at the start of all development scripts76- Prefer concision over verbosity77- If performance is at least almost equivalent or better, prefer in descending78 order:79 - zsh expansions80 - zsh globs81 - zsh builtins82 - zsh loops83 - external commands84- Make variables local & readonly when possible85- Use:86 - `cp -c` instead of `cp`87 - `trash` instead of `rm`8889## Swift9091mas is a SwiftPM project that uses Swift Argument Parser to interact with the92command-line.9394### Apple Private Frameworks9596The `PrivateFrameworks` SwiftPM target exposes the following Apple private97frameworks (via Objective-C headers extracted from the DSC) to deploy App Store98apps:99100- **CommerceKit:** Controllers101- **StoreFoundation:** Models102103Use private frameworks only when public APIs are insufficient.104105Newer Apple private frameworks (e.g., AppStoreDaemon & AppleMediaServices) seem106to supersede the currently used ones, but the newer ones seem usable only by107code with Apple-exclusive entitlements.108109### Swift Source Folder Hierarchy110111Swift source is organized in subfolders of `Sources/mas`:112113- **Commands:** CLI implementation114- **Models:** Data types & suppliers115- **Utilities:** Utilities116117### Command Implementation Patterns118119Commands follow a consistent structure:120121- Commands are nested structs within the `MAS` main command122- Use `@OptionGroup` to compose reusable argument sets from dedicated types123 that conform to `ParsableArguments`124- Implement `func run() async { … }` as the main command entry point125- Use the static `MAS.printer` for all output to ensure consistent formatting126- Call methods on `AppStoreAction` enum cases (accessible via the `AppStore`127 typealias) to execute business logic, e.g., `await AppStore.install.apps(…)`128129### Style Essentials130131- Name most function parameters132- Capitalize acronym & initialism characters consistently (e.g., `HTTPRequest`,133 not `HttpRequest`)134- Shadow variables if the respective original will no longer be used135- Strongify weak references instead of evaluating them multiple times136137### Code Preference Hierarchies138139Each subsection contains code preferences in descending order.140141Within this section & all subsections, `X` is a placeholder for any type name.142143#### Naming1441451. Standardized name1462. Concise name1473. Verbose name148149#### Concision/Verbosity1501511. Concise code, e.g.:152 - Optional binding shorthand (e.g., `if let x { … }`, not153 `if let x = x{ … }`)1542. Verbose code155156#### Architecture1571581. Composition1592. Protocol conformance1603. Class inheritance161162#### Typing1631641. Inferred type, e.g.:165 - `var a = [X]()`166 - `var o = X?.none`167 - `var c: X { .init() }`168 - `f(array: .init())`169 - `f(dictionary: .init())`1702. Cast type, e.g.:171 - `var a = [] as [X]`172 - `var o = nil as X?`1733. Explicit type, e.g.:174 - `var a: [X] = .init()`175 - `var o: X? = nil`176 - `var c: X { X() }`177 - `f(array: [])`178 - `f(dictionary: [:])`179180#### Functional1811821. Functional1832. Non-functional184185#### Value Inlining/Binding1861871. Inlined single-use value1882. `let` multiple-use value1893. `var` multiple-use value190191#### Code Inlining/Reuse1921931. Inlined single-use code (unless inlined code is much more complex)1942. Computed property1953. Function196197#### Optional Handling1981991. Nil-coalescing operator (`??`)2002. Ternary operator2013. `Optional.map(_:)` / `Optional.flatMap(_:)`2024. Single `guard`2035. `if` / `else` (no `else if`)2046. `switch`2057. Multiple `guard`2068. `if` / `else if`… / `else`2079. `preconditionFailure(_:file:line:)`20810. Forced unwrapping (`!` suffix)20911. `fatalError(_:file:line:)`210211#### Throwing2122131. Typed throws (`throws(ErrorType)`)2142. Untyped rethrows (`rethrows`)2153. Untyped throws (`throws`)216217#### Code Reuse2182191. Framework/library call2202. Custom code221222#### Constants2232241. Global `let`2252. `enum` `static let`2263. `struct` `static let`2274. `class` `static let`228229#### Preferred Types2302311. Unaliased infrequent tuple/closure2322. Type-aliased frequent tuple/closure2333. `enum`2344. `struct`2355. `actor`2366. `final class`2377. `class`238239#### Type Syntax2402411. Concision:242 - Generics: `<T: X>`243 - Optional: `X?`244 - Collection: `[X]`245 - Dictionary: `[X:X]`2462. Verbosity:247 - Generics: `where T: X`248 - Optional: `Optional<X>`249 - Collection: `Array<X>`250 - Dictionary: `Dictionary<X, X>`251252#### Void Types2532541. `()` for void parameter type2552. `Void` for void return type256257#### Closure Syntax2582591. Trailing closure2602. Inline closure261262#### Closure Arguments2632641. Shorthand argument names (e.g., `$0`) iff one-line closure2652. Explicit argument names for multi-line closure266267#### Functional Arguments2682691. KeyPath2702. Function reference2713. Closure272273#### Strict Memory Safety2742751. Memory-safe code (i.e. not `unsafe`)2762. `unsafe` code iff a memory-safe alternative:277 - Is not available from frameworks/libraries278 - Is too difficult to implement properly & performantly279280### Testing Requirements281282- Add tests for all non-trivial changes283- Implement in [Swift Testing](https://github.com/swiftlang/swift-testing)284- Derive test file paths from source file paths:285 - replace the `Sources/mas` source path folder prefix with `Tests/MASTests`286 - prepend `MASTests+` to the source file name287 - e.g., `Sources/mas/Commands/X.swift` →288 `Tests/MASTests/Commands/MASTests+X.swift`289- Use force unwrapping in tests where appropriate290
Also in mas-cli/mas
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| mas-cli/masGEMINI.md · 12k | GEMINI.md | buildtestlint-formatstyle+3 | 65/100 | 2 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| trick77/agents-md-syncAGENTS.md · 2 | AGENTS.md | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| SkeneTechnologies/skene-cookbookAGENTS.md · 51 | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 2 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| wpscanteam/wpscanAGENTS.md · 9.7k | AGENTS.md | setupbuildteststyle+6 | 100/100 | 2 days ago | |
| OnlyTerp/prompt-cache-skillsAGENTS.md · 112 | AGENTS.md | setupbuildtestlint-format+5 | 100/100 | 3 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| aaif-goose/gooseAGENTS.md · 52k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 3 days ago |
