Open source ยท MIT

Open source, MIT. Read every line.

AI Usage Menu is free software under the MIT license. The Swift provider readers, build script and parser tests show how the app gets each reading onto your Mac. Inspect the code that touches your data, build the app yourself or contribute support for another provider.

Read the code that touches your data

The app makes no network requests except an update check, when it opens and once a day, which you can turn off.

Claude Code reader

app/Sources/ClaudeCodeProvider.swift

Runs the local /usage command and parses its output.

    func read() async -> ProviderSnapshot {
        guard let binary = await resolve() else { return .init(asOf: Date(), state: .notInstalled) }
        let started = Date()
        do {
            try FileManager.default.createDirectory(at: workdir, withIntermediateDirectories: true)
            let output = try await LocalCommand.runOffPool(binary, ["-p","/usage","--output-format","json","--no-session-persistence","--strict-mcp-config","--mcp-config",#"{"mcpServers":{}}"#,"--setting-sources","project,local"], in: workdir, extraEnvironment: Self.quietEnvironment)
            struct Envelope: Decodable { let result: String }
            let body = (try? JSONDecoder().decode(Envelope.self, from: Data(output.stdout.utf8)))?.result ?? output.stdout
            var snapshot = ClaudeParser.parse(body.isEmpty ? output.stderr : body, now: Date())
View on GitHub

Codex log reader

app/Sources/CodexProvider.swift

Reads the newest session from the end of its local log.

    static func latest(in file: URL) throws -> ProviderSnapshot? {
        let handle = try FileHandle(forReadingFrom: file)
        defer { try? handle.close() }
        var position = try handle.seekToEnd()
        var suffix = Data()
        var skippingLongLine = false
        while position > 0 {
            let length = Int(min(position, 65536))
            position -= UInt64(length)
            try handle.seek(toOffset: position)
            guard let data = try handle.read(upToCount: length), data.count == length else { throw CocoaError(.fileReadUnknown) }
View on GitHub

Updater

app/Sources/Updater/UpdateService.swift

Creates the updater that checks at launch and once a day.

    private func updater() -> SPUUpdater {
        if let controller { return controller.updater }
        let made = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: self, userDriverDelegate: nil)
        controller = made
        return made.updater
    }

    /// Turns the daily check on or off. On: checks now if the last check is over a day old.
View on GitHub

Network source test

app/Tests/ProviderTests.swift

Checks app sources for network APIs outside the updater.

    func testNoNetworkCodeOutsideUpdater() throws {
        let dir = URL(fileURLWithPath:#filePath).deletingLastPathComponent().deletingLastPathComponent().appendingPathComponent("Sources")
        let files = try XCTUnwrap(FileManager.default.enumerator(at:dir,includingPropertiesForKeys:nil))
        let pattern = #"\b(URLSession\w*|NWConnection\w*|CFStream\w*|CF(Read|Write)StreamCreatePairWithSocket\w*|socket|connect|getaddrinfo|WKWebView|NSURLConnection)\b|import\s+(Network|CFNetwork|WebKit)\b"#
        // Comments may mention these words (the provider headers do), so strip them first.
        func code(_ text: String) -> String {
            text.replacingOccurrences(of: #"/\*[\s\S]*?\*/"#, with: "", options: .regularExpression)
                .replacingOccurrences(of: #"//[^\n]*"#, with: "", options: .regularExpression)
View on GitHub

Changelog

  1. v1.0.2
    • New versions now show up as soon as you open the app, not only once a day.
    • Check for updates and see your version right in Settings > About.
    • ```
    • 34ba3cbfd691bc23311f71e707c2076f35dc970f2f0079cbada85f8e6c9d2cf5 AIUsageMenu.dmg
    • fd5f0f6bd67fc3f365238fa838d42b7c7c573ebcf28cbc05490084c8abf61282 AIUsageMenu-1.0.2.zip
  2. v1.0.1
    • The menu bar and Dock no longer show a warning while your first reading is loading.
    • ```
    • dc1cb4bc42e0d87d4d0935e08dbc67ca7e989ed890c88b15e809a4e966d42ce9 AIUsageMenu.dmg
    • 0265847d85b3ee879914975774ed20a53697aa869a9cafc0b63a5024066c3b1a AIUsageMenu-1.0.1.zip
    • ```
  3. v1.0.0
    • See your Claude Code and Codex plan limits in the menu bar and the Dock, with no cookie or API key to paste.
    • Know when each limit resets, and whether you're on pace to run out before it does.
    • See what's using your Claude limit, from activity on this Mac only.
    • ```
    • 8074963700a14c8c6e6ed4ba8f316f249444efe80501ded2d0d9f38d84ae1906 AIUsageMenu.dmg
All releases

Install two ways

Download the signed app, or build it from the source yourself.

Download the signed DMG
  1. Open the downloaded DMG
  2. Drag AI Usage Menu to Applications
  3. Open it and choose your menu bar and Dock views

Requires macOS 13 or later on Apple silicon or Intel.

How to add a provider

Implement the provider interface, map its output to usage windows and add fixtures covering a successful reading, a missing reading and an error. Follow the contribution guide for review. The Claude Code and Codex readers shown above are the patterns to follow.

Contributing and security

Read the contributing guide and code of conduct before submitting changes. Use the security policy to report a vulnerability privately.

License

The MIT license permits use, modification and redistribution with its copyright and license notice. For a release binary, use the download page to check distribution and verification details.

What can I inspect in an open source Claude usage tracker?

In an open source Claude usage tracker, the provider interface and parsing tests tell you more than a screenshot alone. Begin with the Claude reader to see how a local command becomes a usage snapshot. Then follow the parser into a test fixture containing the labels, fractions and reset times it expects.

Where do releases live on GitHub?

The project's GitHub repository is the source for release notes, licenses and published binaries. Each release lists what changed and links the signed, notarized disk image.

How do I contribute to a Swift menu bar app?

For a contribution to this Swift menu bar app, a small fixture is a useful starting point. Capture a representative provider response with personal identifiers removed, then state the behavior you expect from the parser. A missing limit, an explicit zero and a reached-limit message can all arrive in slightly different records.

Explore AI Usage Menu

Last updated

AI Usage Menu

Free for your Mac. Nothing to paste.

Claude Code and Codex limits in your menu bar and Dock, for macOS 13 or later.