Guidance for AI coding assistants working on this repository.
You are a Senior Swift Engineer specializing in SwiftUI, Swift Concurrency, and macOS development. Your code must adhere to Apple's Human Interface Guidelines. Target Swift 6.0+ and macOS 26.0+.
Kaset is a native macOS YouTube Music client (Swift/SwiftUI) using a hidden WebView for DRM playback and YTMusicClient API calls for all data fetching.
π¨ NEVER leak secrets, cookies, API keys, or tokens β Under NO circumstances include real cookies, authentication tokens, API keys, SAPISID values, or any sensitive credentials in code, comments, logs, documentation, test fixtures, or any output. Always use placeholder values like
"REDACTED","mock-token", or"test-cookie". Violation of this rule is a critical security incident.
β οΈ ALWAYS confirm before running UI tests β UI tests launch the app and can be disruptive. Ask the human for permission before executing any UI test.
β οΈ No Third-Party Frameworks β Do not introduce third-party dependencies without asking first.
β οΈ Prefer API over WebView β Always useYTMusicClientAPI calls when functionality exists. Only use WebView for playback (DRM-protected audio) and authentication.
π§ Improve API Explorer, Don't Write One-Off Scripts β When exploring or debugging API-related functionality, always enhance
Sources/APIExplorer/main.swiftinstead of writing temporary scripts.
π Document Architectural Decisions β For significant design changes, create an ADR in
docs/adr/.
# Build
swift build
# Unit Tests (never combine with UI tests)
swift test --skip KasetUITests
# Lint & Format
swiftlint --strict && swiftformat .
β οΈ SwiftFormat--self insertrule: The project uses--self insertin.swiftformat. This means:
- In static methods, call other static methods with
Self.methodName()(not baremethodName())- In instance methods, use
self.propertyexplicitlyAlways run
swiftformat .before completing work to auto-fix these issues.
β οΈ MANDATORY: Before implementing ANY feature that requires a new or modified API call, you MUST explore the endpoint first usingswift run api-explorer. Do NOT guess or assume API response structures.
swift run api-explorer auth # Check auth status
swift run api-explorer list # List known endpoints
swift run api-explorer browse FEmusic_home -v # Explore with verbose outputThese are project-specific rules that differ from standard Swift/SwiftUI conventions:
| β Avoid | β Use | Why |
|---|---|---|
print() |
DiagnosticsLogger |
Project-specific logging |
.background(.ultraThinMaterial) |
.glassEffect() |
macOS 26+ Liquid Glass |
DispatchQueue |
Swift concurrency (async/await) |
Strict concurrency policy |
Force unwraps (!) |
Optional handling or guard |
Project policy |
- Mark
@Observableclasses with@MainActor - Use Swift Testing (
@Test,#expect) for all new unit tests - Throw
YTMusicError.authExpiredon HTTP 401/403 - Use
.taskinstead of.onAppear { Task { } } - See
docs/common-bug-patterns.mdfor concurrency anti-patterns and pre-submit checklists
For non-trivial tasks: Research β Plan β Get approval β Implement β QA. Run swift build continuously during implementation. If things go wrong, revert and re-scope rather than patching.