agentleFS
victorhqcvictorhqc/filbert/.agents/skills/writing-code/SKILL.md

writing-code

Skill4 starsChanged 9 days agoMITView on GitHub

Write or change production code in this repo — the coding standards, the validation gate, and the self-review checklist. Use this whenever you implement a spec item, add or edit Swift in Sources/, add a dependency, or are about to hand a code change back to the user. Covers naming, guard clauses, side-effect boundaries, DRY, idiomatic Swift, commenting rules (the minimal-comments skill, no spec citations in code), the validation gate, and what to re-check before notifying the user.

  • Installs packages

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. classroomio/classroomio★ 1.7ksame name
    2. MedicV2/Claude-Skills★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository4 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 5 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When writing a provider module:

    line 64
  2. Distinctive:

    Do not commit, push, or otherwise touch git on your own.

    line 88
  3. Distinctive:

    Treat the gate as a literal checklist.

    line 108
  4. Very specific:

    swiftformat --lint .: must print 0/N files require formatting.

    line 145
  5. Very specific:

    swiftlint: must report 0 serious violations.

    line 148
  6. Very specific:

    swift test: must show 0 failures.

    line 153
  7. Very specific:

    All four Python test scripts: must report OK and exit with status 0.

    line 154
  8. Very specific:

    If swiftformat or swiftlint is not installed, tell the user to install the version pinned in Mintfile.

    line 158
  9. Very specific:

    If Swift itself is not available (swift build fails with "command not found"), tell the user to install Xcode Command Line Tools with …

    line 163
  10. Distinctive:

    After the gate passes but before handing off, re-read every file you changed and verify:

    line 169
  11. Distinctive:

    If self-review turns up issues, fix them and re-run the validation gate before proceeding.

    line 188

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Writing code

This is a macOS menu-bar app that makes network calls to AI provider APIs and stores credentials in the Keychain. Be methodical and safety-obsessed — verify every change. No quick fixes or temporary hacks unless the user explicitly asks. You have the authority and the obligation to push back on requests that break architectural integrity, type safety, or the Spec-First protocol.

Code follows a spec. If there is no spec for the change, stop and use the writing-specs skill first.

1. Where code lives

  • Sources/App — the macOS app target: menu bar (MenuBarExtra), popover, widgets, app lifecycle (LSUIElement).
  • Sources/Core — the provider hub: AIProvider protocol, registry, refresh scheduling, data aggregation, Keychain access.
  • Sources/Providers/<Name> — one module per provider. Depends only on Core. Implements AIProvider.
  • Tests/ — mirrors the Sources/ layout. Unit tests per module, integration tests for provider hub + provider interactions.

2. Coding standards

  1. Naming — intention-revealing. No hidden "magic".
  2. Guard clauses — prefer guard + early return over deep nesting.
  3. Side effects at the boundaries — each function does one thing. Network calls and Keychain access happen at well-defined edges.
  4. DRY, but no premature abstraction — explicit beats implicit.
  5. Idiomatic Swift — follow the language's conventional patterns. Use async/await, Result types, and SwiftUI idioms where appropriate.
  6. Protocol-oriented — the provider architecture depends on it. Each provider is a struct or actor conforming to AIProvider. The hub talks to the protocol, never to a concrete provider.
  7. Comments — follow the minimal-comments skill. If it is not installed, tell the user to run npx skills add victorhqc/skills.sh --skill minimal-comments. This repo adds two rules:
    • No spec or AC citations in code. No (providers 02), AC1, // ── AC3 ──, or "implements spec". Specs cite each other; code does not cite specs. If a spec shapes a non-obvious decision, state the reason in plain words. Delete existing citations on sight.
    • /// vs // — SwiftFormat's docComments rule (default-on, no .swiftformat opt-out in this repo) decides the syntax. A comment directly above a declaration must be ///; any other comment must be //. Never downgrade a surviving why to // to make it "less official".
  8. Dependencies — if a package is not in Package.swift, add it before using it. Prefer Apple frameworks over third-party packages.
  9. Concurrency — use Swift's structured concurrency (async/await, Task, @MainActor). No bare DispatchQueue unless interfacing with a callback-based API.

Provider rules

When writing a provider module:

  • Implement AIProvider and nothing else public. Internal helpers are fine.
  • One URLSession per provider, configured with the provider's base URL and default headers.
  • Parse the provider's response into the shared ProviderQuota model. Map provider-specific fields don't leak into the core.
  • Handle auth errors (401), rate limits (429), and network errors distinctly.
  • Log only failed operations with safe identifiers and numeric error codes. Never log API keys, auth headers, or raw response bodies.

3. The implementation loop

For each spec item, in order:

  1. Sync — re-read the spec file; the user may have edited it.
  2. Execute — perform the next unchecked item, only that item.
  3. Record — mark the item [x] in the spec and log any new findings.
  4. Validate — run the full validation gate (below), every step, in order. Do not subset it. Build + test alone is not enough — CI runs swiftformat --lint ., swiftlint, a release build, and tests; so must you. If any step fails, fix and restart from step 1.
  5. Self-review — after the gate passes, review your own work (below).

Do not commit, push, or otherwise touch git on your own. Hand the git commands to the user to run.

4. Validation gate

This is the single most important step in the loop. The commands below are the exact gate CI runs in .github/workflows/ci.yml. Run all of them, in order, from the workspace root — every one must pass before you notify the user. Running only swift build + swift test is not enough: CI also runs the SwiftFormat lint and a release build, so any of those failing on CI is a regression you shipped. Keep the gate in sync with ci.yml — if a step is added there, add it here.

SwiftFormat and SwiftLint versions are pinned in Mintfile. CI downloads the pinned prebuilt binaries from GitHub releases and runs them directly (swiftformat / swiftlint). Locally you can use Homebrew (swiftformat / swiftlint directly), but your installed versions must match the Mintfile pins — otherwise a green local run will not predict a green CI run. If your versions drift, grab the pinned prebuilt binaries (see DEVELOPMENT.md).

Treat the gate as a literal checklist. Run each command, read its full output, and only move to the next when the previous is green. If any step fails, fix the code and restart the gate from step 1 — earlier steps can regress when you edit to fix a later one.

# 1. Format — CI step "SwiftFormat (lint)" (version pinned in Mintfile;
#    locally: swiftformat matching the pin, via Homebrew or prebuilt download)
swiftformat --lint .

# 2. Lint — CI step "SwiftLint" (version pinned in Mintfile)
swiftlint

# 3. Build — CI step "Build (debug)"
swift build

# 4. Build — CI step "Build (release)" — catches optimizer-only failures
swift build -c release

# 5. Tests — CI step "Test"
swift test

# 6. Workflow tests — CI step "Workflow tests"
python3 scripts/test-automatic-updates.py

# 7. Highlights tests — CI step "Release highlights tests"
python3 scripts/test-release-highlights.py

# 8. Cask tests — CI step "Homebrew cask tests"
python3 scripts/test-homebrew-cask.py

# 9. Packaging tests — CI step "Local signing and startup tests"
python3 scripts/test-local-signing.py

What counts as "passing"

  • swiftformat --lint . must print 0/N files require formatting. Any error: line is a failure — fix the formatting in the file, do not silence the rule.
  • swiftlint must report 0 serious violations. Warnings are not failures, but if a warning appears in a file you changed, fix it. Pre-existing warnings in untouched files are out of scope — note them but don't fix.
  • swift build and swift build -c release must end with Build complete!.
  • swift test must show 0 failures.
  • All four Python test scripts must report OK and exit with status 0.

When a tool isn't installed

  • If swiftformat or swiftlint is not installed, tell the user to install the version pinned in Mintfile. Either match it with Homebrew (brew install swiftformat swiftlint, then verify the version matches the pin) or download the pinned prebuilt binaries (see DEVELOPMENT.md). Do not skip the gate — tell the user the gate is blocked.
  • If Swift itself is not available (swift build fails with "command not found"), tell the user to install Xcode Command Line Tools with xcode-select --install.

5. Self-review checklist

After the gate passes but before handing off, re-read every file you changed and verify:

  • Acceptance-criteria alignment — re-read the ACs from the spec; does the code satisfy them, or has it drifted?
  • Naming & readability — are new functions, types, and files named with intention? Would someone understand them without context?
  • Side effects — did you change behavior in code paths you didn't intend to touch?
  • Provider isolation — did any change to one provider leak into another provider or into the core?
  • Test quality — do the tests assert the right things, or are they just "tests to pass"?
  • Scope creep — did you change anything beyond the spec?
  • Comments — every remaining comment passes the minimal-comments skill. No spec citations and no AC markers anywhere.
  • No secrets in logs — no API keys, tokens, or auth headers in print(), os_log, or debug output.

If self-review turns up issues, fix them and re-run the validation gate before proceeding. When self-review is clean, notify the user for review.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.