Generate optimized queries, caching, and indexes for Frappe performance. Use when optimizing slow queries, implementing caching, or improving performance.
Generates optimized queries, caching, and indexes for Frappe apps. Use when fixing slow queries, eliminating N+1 problems, or improving performance.
/plugin marketplace add Venkateshvenki404224/frappe-apps-manager/plugin install frappe-apps-manager@frappe-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Generate performance-optimized code including efficient queries, caching strategies, and database indexes for Frappe applications.
Claude should invoke this skill when:
Optimized Report Query:
# Efficient query with proper indexing
def get_sales_summary(from_date, to_date):
return frappe.db.sql("""
SELECT
si.customer,
c.customer_name,
c.customer_group,
COUNT(si.name) as invoice_count,
SUM(si.grand_total) as total_amount
FROM `tabSales Invoice` si
INNER JOIN `tabCustomer` c ON c.name = si.customer
WHERE si.posting_date BETWEEN %s AND %s
AND si.docstatus = 1
GROUP BY si.customer
ORDER BY total_amount DESC
LIMIT 100
""", (from_date, to_date), as_dict=True)
# Add index for performance
frappe.db.add_index('Sales Invoice', ['customer', 'posting_date', 'docstatus'])
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
if price:
frappe.cache().set_value(cache_key, price, expires_in_sec=3600)
return price
Bulk Update Pattern:
def bulk_update_items(updates):
"""Update multiple items efficiently"""
# updates = [{'item_code': 'ITEM-001', 'is_active': 1}, ...]
# Build single query
item_codes = [u['item_code'] for u in updates]
frappe.db.sql("""
UPDATE `tabItem`
SET is_active = 1,
modified = NOW(),
modified_by = %s
WHERE name IN %s
""", (frappe.session.user, tuple(item_codes)))
frappe.db.commit()
Performance Examples:
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.