performance-patterns
Skill8 starsChanged 8 months agoMITView on GitHub
Use when optimizing OmniFocus MCP operations, diagnosing slow queries, adding new filtering logic, or modifying how data is fetched from OmniFocus. Covers the N+1 elimination pattern, batch fetching, conditional filter-first architecture, and known operation timings. Also use when adding any new get_* or filter parameter.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- s-morgan-jeffries/apple-mail-mcptheir own version, first seen Oct 9, 2026
- s-morgan-jeffries/apple-mail-fast-mcptheir own version, first seen Sep 7, 2026
- intel/skillstheir own version, first seen Sep 3, 2026
- intel/intel-performance-skillstheir own version, first seen May 22, 2026
- farming-labs/fm-skillstheir own version, first seen Mar 14, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- intel/intel-performance-skills★ 332same name
- s-morgan-jeffries/apple-mail-mcp★ 104same name
- s-morgan-jeffries/apple-mail-fast-mcp★ 103same name
- farming-labs/fm-skills★ 35same name
- intel/skills★ 30same 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 repository5 other files it gives its agents.
- .claude/CLAUDE.mdCLAUDE.md
- api-designSkill
- applescript-omnifocusSkill
- integration-testingSkill
- releaseSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 73
When you don't need all properties, fetch only what you need:
- Distinctive: line 93
Rule of thumb: Use AppleScript filtering when it eliminates data transfer (fewer tasks to serialize).
- Distinctive: line 104
Don't add properties to the "always extract" list unless they're commonly needed.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
OmniFocus MCP Performance Patterns
AppleScript round-trips via osascript are the dominant performance cost. Every optimization in this project reduces the number of subprocess calls.
Known Operation Timings
| Operation | Time | Notes |
Single osascript call overhead | 100-300ms | Minimum cost per subprocess |
get_tasks() — 188 tasks, no filters | ~2.3s | Baseline with full property extraction |
get_projects() — 33 projects | ~0.9s | After N+1 fix |
get_projects() — 33 projects (BEFORE fix) | ~7.6s | N+1 pattern: 1 call per project |
| Individual task update | 200-400ms | Single property change |
get_tasks() with overdue filter | ~0.3s | Filter-first eliminates non-matching tasks early |
| Database safety check | ~100ms | Runs before every destructive operation |
Timeout defaults: 60s standard, 300s maximum. Configurable per operation.
Pattern 1: Eliminate N+1 Queries
The most impactful optimization in this project. Before the fix, filtering projects by their tasks required one AppleScript call per project:
# BAD: N+1 pattern (33 projects = 33 calls = 7.6s)
for project in projects:
tasks = get_tasks(project_id=project.id) # 230ms each!
if meets_filter(tasks):
results.append(project)
# GOOD: Batch pattern (33 projects = 1 call = 0.9s)
all_tasks_by_project = _get_tasks_batch_for_filtering() # Single call
for project in projects:
tasks = all_tasks_by_project.get(project.id, [])
if meets_filter(tasks):
results.append(project)Implementation: _get_tasks_batch_for_filtering() fetches minimal data (id, projectId, dueDate) for ALL tasks in one AppleScript call, returning a {projectId: [tasks]} dictionary.
Result: 8.5x faster (7.6s -> 0.9s for 33 projects). Scales linearly — 500 projects would go from 115s to 13.5s.
Apply this pattern whenever you need to cross project boundaries for filtering or aggregation.
Pattern 2: Conditional Filter-First Architecture
get_tasks() has a critical optimization: it detects whether "selective filters" are active and changes its execution order accordingly.
Selective filters: flagged_only, overdue, dropped_only, blocked_only, next_only, relative date ranges
IF selective filters active:
1. Apply filters in AppleScript (cheap — just checking properties)
2. Extract full properties only for matching tasks (expensive)
Result: 82-88% faster for selective queries
IF no selective filters:
1. Extract full properties for all tasks
2. Apply post-processing filters in Python
Result: Avoids overhead of empty filter checksWhy this matters: Extracting 27 properties per task is expensive. If you're only looking for 5 overdue tasks out of 188, filtering first means you only extract properties for 5 tasks instead of 188. This is a 19x speedup for selective queries.
When adding new filter parameters: Determine whether the filter is "selective" (likely to match a small subset) or "broad" (likely to match most tasks). Selective filters should go into the filter-first path.
Pattern 3: Minimize Data Per Call
When you don't need all properties, fetch only what you need:
-- GOOD: Fetch only what's needed for filtering
set taskData to {id of t, project of t, due date of t}
-- BAD: Fetch everything when you only need to filter
set taskData to {id, name, note, status, flagged, due date, defer date, ...}_get_tasks_batch_for_filtering() demonstrates this — it fetches only id, projectId, and dueDate because that's all the project filtering logic needs.
Pattern 4: Python Post-Processing vs AppleScript Filtering
Some filters are better applied in Python after fetching data:
- Tag filtering (OR/NOT modes): Done in Python via
_filter_tasks_by_tags()because AppleScript tag matching is limited - Tag filtering (AND mode): Done in AppleScript for efficiency, then verified in Python for consistency
- Date range filtering: Simpler to compare ISO dates in Python than to build date comparison logic in AppleScript
Rule of thumb: Use AppleScript filtering when it eliminates data transfer (fewer tasks to serialize). Use Python filtering when the logic is complex or when the data is already fetched.
Anti-Patterns
Repeated Safety Checks
Each destructive operation calls _verify_database_safety() which runs an AppleScript to fetch the database name (~100ms). For batch operations that call multiple destructive methods, this check runs multiple times unnecessarily. Consider caching the result for the session.
Large AppleScript Blocks
Very large AppleScript strings (1000+ lines) can be slow to parse. If a script grows unwieldy, consider splitting into two calls: one for data retrieval, one for data processing, with Python bridging them.
Unnecessary Property Extraction
Don't add properties to the "always extract" list unless they're commonly needed. Each additional property adds serialization overhead for every task in every query.
Profiling Infrastructure
The project has performance profiling tests in tests/test_profile_performance.py and test data generation scripts in scripts/local/setup_profiling_data.sh.
To profile a change:
- Switch to test database:
./scripts/local/switch_to_test_db.sh - Generate test data:
./scripts/local/setup_profiling_data.sh - Run profiling:
pytest tests/test_profile_performance.py -v - Switch back:
./scripts/local/switch_to_prod_db.sh
Detailed Analysis
For the complete performance analysis including Phase 1/Phase 2 optimization results and empirical data, see:
docs/performance/GET_TASKS_PERFORMANCE_ANALYSIS.mddocs/performance/PERFORMANCE_OPTIMIZATION_SUMMARY.md
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
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.

