performance-optimization-patterns

A collection of performance guidelines for a point-of-sale system, covering database queries, React user interfaces, and application programming interfaces (APIs). React is a library for building web interfaces.

In plain words
What is it for?
It is for measuring operations, avoiding unnecessary React re-renders, and setting performance targets for core POS actions.
Why use it?
It helps identify and reduce delays in ordering, payments, kitchen updates, searching, database work, and screen rendering.

Cursor rule for Cursor

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 rules/madebyaris/poinf-of-sales/performance-optimization-patterns
Clone the repo
git clone --depth 1 https://github.com/madebyaris/poinf-of-sales

Made for: Cursor.

Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 8,737 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.00016 $0.08737
Opus 5 $0.00008 $0.04369
Sonnet 5 $0.00003 $0.01747
Haiku 4.5 $0.00002 $0.00874

Measured yesterday against content hash 841d4978fe9e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

performance-optimization-patterns 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 yesterday.

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.

.cursor/rules/performance-optimization-patterns.mdc · 1,223 lines

How it starts

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

⚡ Performance Optimization Patterns

🎯 Performance Philosophy for POS Systems

Critical Performance Metrics

  • Order Creation: < 500ms from click to confirmation
  • Payment Processing: < 2s for complete transaction
  • Kitchen Updates: Real-time (< 100ms propagation)
  • Product Search: < 200ms for instant results
  • Database Queries: < 100ms for typical CRUD operations

Performance Monitoring Strategy

// Performance monitoring utilities
class PerformanceMonitor {
  static timeOperation<T>(name: string, operation: () => Promise<T>): Promise<T> {
    console.time(name);
    return operation().finally(() => console.timeEnd(name));
  }

  static measureRender(componentName: string) {
    return (Component: React.ComponentType<any>) => {
      return React.memo(Component, (prevProps, nextProps) => {
        const start = performance.now();
        const shouldUpdate = !Object.is(prevProps, nextProps);
        const end = performance.now();
        
        if (end - start > 1) {
          console.warn(`${componentName} render check took ${end - start}ms`);
        }
        
        return !shouldUpdate;
      });
    };
  }
}

🗄️ Database Performance Patterns

Optimized Query Patterns

// ✅ CORRECT: Efficient query with proper indexing
func (h *OrderHandler) GetOrdersWithPagination(c *gin.Context) {
    page := getIntParam(c, "page", 1)
    perPage := getIntParam(c, "per_page", 20)
    status := c.Query("status")
    
    // Use indexed columns in WHERE clause
    query := `
        SELECT 
            o.id, o.order_number, o.status, o.total_amount, o.created_at,
            u.username, t.table_number,
            COUNT(*) OVER() as total_count
        FROM orders o
        LEFT JOIN users u ON o.user_id = u.id
        LEFT JOIN dining_tables t ON o.table_id = t.id
        WHERE ($1 = '' OR o.status = $1)
            AND o.created_at >= CURRENT_DATE - INTERVAL '7 days'
        ORDER BY o.created_at DESC
        LIMIT $2 OFFSET $3
    `
    
    offset := (page - 1) * perPage
    rows, err := h.db.Query(query, status, perPage, offset)
    // ... handle results
}

// ✅ CORRECT: Batch insert for order items
func (h *OrderHandler) CreateOrderWithItems(c *gin.Context) {
    tx, err := h.db.Begin()
    if err != nil {
        // handle error
        return
    }
    defer tx.Rollback()

    // Create order
    var orderID string
    err = tx.QueryRow(`
        INSERT INTO orders (customer_name, order_type, status, total_amount)
        VALUES ($1, $2, $3, $4)
        RETURNING id
    `, req.CustomerName, req.OrderType, "pending", req.TotalAmount).Scan(&orderID)

    // Batch insert order items (much faster than individual inserts)
    if len(req.Items) > 0 {
        valueStrings := make([]string, 0, len(req.Items))
        valueArgs := make([]interface{}, 0, len(req.Items)*4)
        
        for i, item := range req.Items {
            valueStrings = append(valueStrings, fmt.Sprintf("($%d, $%d, $%d, $%d)", 
                i*4+1, i*4+2, i*4+3, i*4+4))
            valueArgs = append(valueArgs, orderID, item.ProductID, item.Quantity, item.Price)
        }

        stmt := fmt.Sprintf(`
            INSERT INTO order_items (order_id, product_id, quantity, price)
            VALUES %s
        `, strings.Join(valueStrings, ","))

        _, err = tx.Exec(stmt, valueArgs...)
        if err != nil {
            return // Rollback automatically called
        }
    }

    err = tx.Commit()
    // ... handle success
}

Read the full file on GitHub · 1,223 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. yesterday First seen · 1,223 lines · 16 tokens per session scan A 841d4978fe9e

Subscribe to this mod's changes

performance-optimization-patterns is a cursor rule published in the GitHub repository madebyaris/poinf-of-sales (133 stars, last pushed 1y ago), licensed MIT. It adds 16 tokens to every session and 8,737 once invoked, about $0.0001 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-30.