frappe-performance-optimizer
БесплатноБез исполняемых скриптовНе проверенGenerate optimized queries, caching, and indexes for Frappe performance. Use when optimizing slow queries, implementing caching, or improving performance.
Об этом скилле
Frappe Performance Optimizer
Generate performance-optimized code including efficient queries, caching strategies, and database indexes for Frappe applications.
Global Rules
These Frappe conventions apply to everything this skill generates, and override any conflicting example below.
- Bench commands: use bare
bench(never./env/bin/benchor a full path). Always pass--site <site>explicitly — never run a barebench migrate/bench run-tests. Runbench startin the background and only if it isn't already running. Don't run discovery commands (which bench,bench --version). - DocType files live at
apps/<app>/<app>/<module>/doctype/<name>/<name>.json— the app name appears twice (directory + Python package) — with an empty__init__.pyalongside. Nevermkdirthe folder; write the JSON and runbench --site <site> migrateto create the structure. Don't addcreation,modified,owner,modified_by, ordocstatusas fields — Frappe manages them. - Database & ORM: prefer
frappe.qb.get_query()over rawfrappe.db.sql(). Usefrappe.db.get_all()for server logic (ignores permissions) andfrappe.db.get_list()for user-facing APIs (enforces them). Never usefrappe.db.set_value()on a field with validation or lifecycle logic — load the doc anddoc.save()so controller hooks run. Batch-fetch related records; never query inside a loop (N+1). - Never call
frappe.db.commit()in controllers, request handlers, background jobs, or patches — Frappe auto-commits on success and rolls back on uncaught errors. Flush manually only to make a write visible to a subsequentfrappe.enqueue()(or passenqueue_after_commit=True). - Permissions & APIs: put permission checks inside controller methods (enforced on every call path), not in API wrappers. Type-hint every
@frappe.whitelist()parameter so Frappe validates and casts it, and passmethods=[...]to pin the HTTP verb.
When to Use This Skill
Claude should invoke this skill when:
- User reports slow queries or performance issues
- User wants to add caching
- User needs database indexing
- User mentions performance, optimization, or slow queries
- User wants to eliminate N+1 queries
Capabilities
1. Query Optimization
Prefer frappe.qb.get_query() over raw frappe.db.sql() for joins, aggregations, OR conditions, subqueries, and locking. It auto-joins linked/child fields via dot notation and stays composable. Reach for frappe.db.sql() only for things the builder can't express (CTEs, etc.).
Optimized Report Query (query builder):
def get_sales_summary(from_date, to_date):
query = frappe.qb.get_query(
"Sales Invoice",
fields=[
"customer",
"customer.customer_name as customer_name", # auto-joins Customer
"customer.customer_group as customer_group",
{"COUNT": "name", "as": "invoice_count"},
{"SUM": "grand_total", "as": "total_amount"},
],
filters={
"posting_date": ["between", [from_date, to_date]],
"docstatus": 1,
},
group_by="customer",
order_by="total_amount desc",
limit=100,
)
return query.run(as_dict=True)
# Add a covering index for the hot filter columns
frappe.db.add_index('Sales Invoice', ['customer', 'posting_date', 'docstatus'])
Use get_all for server-side logic (ignores permissions) and get_list for user-facing data (enforces them). Under concurrency, lock the rows you're about to update with for_update=True:
# Row locking to avoid lost updates when two jobs touch the same doc
query = frappe.qb.get_query("Stock Entry", filters={"name": name}, for_update=True)
row = query.run(as_dict=True)
2. Caching Implementation
frappe.cache is an attribute, NOT a callable — use frappe.cache.get_value(...) / frappe.cache.set_value(...), never frappe.cache(). Keys are logical strings (price:ITEM:LIST); the wrapper auto-prefixes them with the site name, so never prefix the database/site name yourself.
Cache Expensive Calculations:
def get_item_price(item_code, price_list, customer=None):
"""Get price with caching"""
cache_key = f"price:{item_code}:{price_list}:{customer or 'default'}"
# Try cache
cached_price = frappe.cache.get_value(cache_key)
if cached_price is not None:
return cached_price
# Calculate price (expensive)
price = frappe.db.get_value('Item Price',
filters={'item_code': item_code, 'price_list': price_list},
fieldname='price_list_rate'
)
# Cache for 1 hour with an explicit TTL
if price:
frappe.cache.set_value(cache_key, price, expires_in_sec=3600)
return price
CRITICAL — pair every cached write with invalidation. Clear the key from the relevant doc lifecycle hook so the cache can't go stale:
class ItemPrice(Document):
def on_update(self):
self._clear_pr
Установить frappe-performance-optimizer в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл frappe-performance-optimizer?
Generate optimized queries, caching, and indexes for Frappe performance. Use when optimizing slow queries, implementing caching, or improving performance.
Как установить скилл frappe-performance-optimizer?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл frappe-performance-optimizer запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic