swift-agent-debug-log

A logging protocol for Swift and iOS applications that records debugging hypotheses as newline-delimited JSON, one JSON object per line, on a host computer or simulator.

In plain words
What is it for?
Use it in Cursor debug sessions to record hypotheses, clear or retrieve logs, and reproduce problems on macOS, iOS simulators, or tests.
Why use it?
It avoids trying to write from an iOS simulator into protected repository paths and gives the debugging tools a defined place to read the logs.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/debugswift/xcodebazelmcp/swift-agent-debug-log
Any agent
npx skills add DebugSwift/XcodeBazelMCP --skill swift-agent-debug-log
Clone the repo
git clone --depth 1 https://github.com/DebugSwift/XcodeBazelMCP

Made for: Claude Code, Codex.

Per session 58 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,109 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00058 $0.01109
Opus 5 $0.00029 $0.00554
Sonnet 5 $0.00012 $0.00222
Haiku 4.5 $0.00006 $0.00111

Measured 2d ago against content hash d33b499e4745, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

swift-agent-debug-log scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/swift-agent-debug-log/SKILL.md · 110 lines

How it starts

The opening of the file, as written. The whole thing — 110 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Swift Agent Debug Log (Cursor DEBUG MODE)

XcodeBazelMCP owns runtime (build, launch, read logs). This skill is the protocol (NDJSON schema, hypothesisId, session cleanup).

Log path strategy

Runtime Where Swift writes How the agent reads
macOS / unit tests Host path from env bazel_ios_agent_debug_log_read
iOS Simulator Documents/agent-debug.ndjson (sandbox-safe) bazel_ios_agent_debug_log_pull or env if using host mount

Never hardcode repo paths like Apps/Consumer/.cursor/debug-*.log in app code — the sim sandbox cannot write there.

Environment (preferred for host / tests)

bazel_ios_build_and_run / bazel_ios_agent_debug_repro pass via launchEnvSIMCTL_CHILD_*:

  • AGENT_DEBUG_LOG_PATH — absolute host path (e.g. <workspace>/.cursor/debug-{session}.log)
  • AGENT_DEBUG_SESSION_ID — Cursor debug session id

Swift reads ProcessInfo.processInfo.environment and appends one NDJSON object per line.

Simulator fallback

If no host path is writable, append NDJSON to:

FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]/agent-debug.ndjson

Then pull with bazel_ios_agent_debug_log_pull (destPath optional copy to .cursor/debug-*.log).

Swift instrumentation (minimal)

func agentDebugLog(
  location: String,
  message: String,
  data: [String: Any] = [:],
  hypothesisId: String,
  runId: String = "pre-fix"
) {
  let env = ProcessInfo.processInfo.environment
  let sessionId = env["AGENT_DEBUG_SESSION_ID"] ?? ""
  let payload: [String: Any] = [
    "sessionId": sessionId,
    "location": location,
    "message": message,
    "data": data,
    "hypothesisId": hypothesisId,
    "runId": runId,
    "timestamp": Int(Date().timeIntervalSince1970 * 1000),
  ]
  guard let line = try? JSONSerialization.data(withJSONObject: payload),
        let str = String(data: line, encoding: .utf8) else { return }
  let row = str + "\n"
  if let path = env["AGENT_DEBUG_LOG_PATH"], !path.isEmpty {
    if let handle = FileHandle(forWritingAtPath: path) {
      handle.seekToEndOfFile(); handle.write(Data(row.utf8)); try? handle.close()
    } else {
      FileManager.default.createFile(atPath: path, contents: Data(row.utf8))
    }
    return
  }
  let doc = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
  let url = doc.appendingPathComponent("agent-debug.ndjson")
  if let handle = try? FileHandle(forWritingTo: url) {
    handle.seekToEndOfFile(); handle.write(Data(row.utf8)); try? handle.close()
  } else {
    try? row.write(to: url, atomically: true, encoding: .utf8)
  }
}

Read the full file on GitHub · 110 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 110 lines · 58 tokens per session scan A d33b499e4745

Subscribe to this mod's changes

swift-agent-debug-log is a skill published in the GitHub repository DebugSwift/XcodeBazelMCP (7 stars, last pushed 1mo ago), licensed MIT. It adds 58 tokens to every session and 1,109 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

benchmark

Run performance + quality benchmarks. ASR reports WER, RTF, process memory, and throughput across engines/variants. Arguments include asr, tts, vad, diarize, asr-quick.

soniqo/speech-swift · 45 tokens

review-pr

Review a pull request for conceptual fit, architecture impact, adversarial failure modes, security risk, docs impact, regression risk, test coverage, and merge readiness. Use when asked to review a PR, check whether a PR is safe to merge, decide if more tests are needed, perform adversarial or security review, or…

soniqo/speech-swift · 71 tokens

test

Run tests. Use after code changes to validate. Arguments: unit (default, no GPU), e2e (with models), filter name, or all.

soniqo/speech-swift · 34 tokens

boutique-best-practices

Best practices for using Boutique with Swift 6 concurrency, @Observable, @ObservationIgnored, Sendable conformance, testing with preview stores, and dependency injection. Use when troubleshooting Boutique issues, migrating to Swift 6, or setting up tests.

mergesort/Boutique · 56 tokens

boutique-store

Create and use Boutique Store for Swift data persistence, including initialization, @Stored controllers, CRUD operations, operation chaining, and granular event monitoring. Use when persisting arrays of items, building data controllers, or working with Boutique's Store type.

mergesort/Boutique · 52 tokens

boutique-stored-values

Persist individual values with Boutique's @StoredValue (UserDefaults) and @SecurelyStoredValue (Keychain), including set, reset, toggle, bindings, keypath setters, array and dictionary helpers, and async observation. Use when storing preferences, settings, feature flags, or sensitive data like auth tokens.

mergesort/Boutique · 68 tokens