apple-notes-debug-bundle
Collect Apple Notes automation debug evidence for troubleshooting. Trigger: "apple notes debug".
What this skill does
# Apple Notes Debug Bundle
## Overview
This debug bundle collects diagnostic information from Apple Notes automation integrations
for troubleshooting AppleScript and JXA (JavaScript for Automation) workflows. It captures
macOS version compatibility, Notes.app account configuration, folder and note counts,
TCC (Transparency, Consent, and Control) permission status, and Shortcuts automation
entitlements. The resulting tarball helps diagnose permission denials, sandbox restrictions,
iCloud sync failures, and scripting bridge errors that commonly block Notes automation.
## Prerequisites
- macOS 12+ with Notes.app configured
- `osascript`, `tar` available (built into macOS)
- Terminal granted Automation permission for Notes.app in System Preferences > Privacy & Security
## Debug Collection Script
```bash
#!/bin/bash
set -euo pipefail
BUNDLE="debug-apple-notes-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$BUNDLE"
# Environment check
echo "=== Environment ===" > "$BUNDLE/environment.txt"
echo "macOS: $(sw_vers -productVersion 2>/dev/null || echo 'not macOS')" >> "$BUNDLE/environment.txt"
echo "Notes.app running: $(pgrep -x Notes > /dev/null && echo Yes || echo No)" >> "$BUNDLE/environment.txt"
echo "Shell: $SHELL ($TERM)" >> "$BUNDLE/environment.txt"
echo "Timestamp: $(date -u)" >> "$BUNDLE/environment.txt"
# Automation permissions (TCC database)
echo "=== TCC Permissions ===" > "$BUNDLE/tcc-status.txt"
sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db \
"SELECT client, auth_value, auth_reason FROM access WHERE service='kTCCServiceAppleEvents'" \
>> "$BUNDLE/tcc-status.txt" 2>/dev/null || echo "Cannot read TCC database (SIP may block)" >> "$BUNDLE/tcc-status.txt"
# Account enumeration via JXA
echo "=== Accounts ===" > "$BUNDLE/accounts.txt"
osascript -l JavaScript -e '
const app = Application("Notes");
const accts = app.accounts();
accts.forEach(a => {
const notes = a.notes().length;
const folders = a.folders().length;
ObjC.import("stdlib"); // ensure stdio
$.system(`echo "${a.name()}: ${notes} notes, ${folders} folders" >> /dev/stdout`);
});
' >> "$BUNDLE/accounts.txt" 2>&1 || echo "JXA account query failed" >> "$BUNDLE/accounts.txt"
# Note count and folder structure
echo "=== Folder Structure ===" > "$BUNDLE/folders.txt"
osascript -l JavaScript -e '
const app = Application("Notes");
app.defaultAccount.folders().forEach(f => {
$.system(`echo " ${f.name()}: ${f.notes().length} notes" >> /dev/stdout`);
});
' >> "$BUNDLE/folders.txt" 2>&1 || echo "Folder query failed" >> "$BUNDLE/folders.txt"
# Shortcuts integration check
echo "=== Shortcuts ===" > "$BUNDLE/shortcuts.txt"
shortcuts list 2>/dev/null | grep -i note >> "$BUNDLE/shortcuts.txt" || echo "No note-related Shortcuts found" >> "$BUNDLE/shortcuts.txt"
# iCloud sync status
echo "=== iCloud Sync ===" > "$BUNDLE/icloud-sync.txt"
brctl status com.apple.Notes 2>/dev/null >> "$BUNDLE/icloud-sync.txt" || echo "brctl not available or Notes not using iCloud Drive" >> "$BUNDLE/icloud-sync.txt"
ls -la ~/Library/Group\ Containers/group.com.apple.notes/ >> "$BUNDLE/icloud-sync.txt" 2>/dev/null || echo "Notes container not found" >> "$BUNDLE/icloud-sync.txt"
# Recent console errors
echo "=== Recent Errors ===" > "$BUNDLE/console-errors.txt"
log show --predicate 'subsystem == "com.apple.notes"' --last 30m --style compact 2>/dev/null \
| tail -50 >> "$BUNDLE/console-errors.txt" || echo "Cannot read system log" >> "$BUNDLE/console-errors.txt"
tar -czf "$BUNDLE.tar.gz" "$BUNDLE" && rm -rf "$BUNDLE"
echo "Bundle: $BUNDLE.tar.gz"
```
## Analyzing the Bundle
```bash
tar -xzf debug-apple-notes-*.tar.gz
cat debug-apple-notes-*/environment.txt # Confirm macOS version
cat debug-apple-notes-*/tcc-status.txt # Check automation permissions
cat debug-apple-notes-*/accounts.txt # Verify note counts per account
cat debug-apple-notes-*/console-errors.txt # Look for sandbox or sync errors
```
## Common Issues
| Symptom | Check in Bundle | Fix |
|---------|----------------|-----|
| `-1743` error (not permitted) | `tcc-status.txt` shows no entry for Terminal | Grant Automation permission: System Settings > Privacy > Automation > Terminal > Notes |
| JXA returns empty arrays | `accounts.txt` shows 0 notes | Notes.app must be open at least once; launch Notes and wait for iCloud sync |
| `execution error: Notes got an error: AppleEvent timed out` | `console-errors.txt` shows timeout | Notes.app is busy syncing; wait for iCloud sync to finish, then retry |
| Folder query fails on shared accounts | `folders.txt` shows error on non-default account | Specify account explicitly: `app.accounts.byName("iCloud")` |
| Shortcuts integration returns empty | `shortcuts.txt` shows no matches | Create a Notes shortcut manually in Shortcuts.app, then re-run |
| `brctl` reports conflict | `icloud-sync.txt` shows conflict state | Open Notes.app, resolve duplicate notes, then force sync via iCloud preferences |
## Automated Health Check
```typescript
import { execSync } from "child_process";
function checkAppleNotesHealth(): {
status: string;
macosVersion: string;
notesRunning: boolean;
accountCount: number;
tccGranted: boolean;
} {
const macosVersion = execSync("sw_vers -productVersion").toString().trim();
const notesRunning = execSync("pgrep -x Notes || true").toString().trim() !== "";
let accountCount = 0;
try {
const raw = execSync(
'osascript -l JavaScript -e \'Application("Notes").accounts().length\''
).toString().trim();
accountCount = parseInt(raw, 10);
} catch { /* Notes not accessible */ }
const tccGranted = accountCount > 0;
return {
status: tccGranted && notesRunning ? "healthy" : "degraded",
macosVersion,
notesRunning,
accountCount,
tccGranted,
};
}
```
## Resources
- [Mac Automation Scripting Guide](https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/)
- [JXA Cookbook](https://github.com/JXA-Cookbook/JXA-Cookbook)
- [Apple Developer — NSAppleScript](https://developer.apple.com/documentation/foundation/nsapplescript)
## Next Steps
See `apple-notes-rate-limits`.
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.