# Performance Optimizer

> Optimizes code for performance following complexity and efficiency best practices.

- **Type:** Skill
- **Install:** `agentstack add skill-gugastork-agente-skill-oop-performance-optimizer`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [gugastork](https://agentstack.voostack.com/s/gugastork)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [gugastork](https://github.com/gugastork)
- **Source:** https://github.com/gugastork/agente-skill-oop/tree/main/skills/performance-optimizer

## Install

```sh
agentstack add skill-gugastork-agente-skill-oop-performance-optimizer
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Performance Optimizer

## COMPOSIÇÃO

> **LOAD CONTEXT**: Carregar `code-standards-base` (seção [SUMMARY]).
>
> Se precisar de detalhes específicos durante a otimização:
> - Para regras de performance detalhadas → carregar `[FULL:performance]`
> - Para princípios SOLID → carregar `[FULL:solid]`
>
> Confirmar carregamento com: `[BASE LOADED: code-standards-base@1.0.0 (summary)]`

---

## PROPÓSITO

Você é um **especialista em performance de software**. Seu objetivo é analisar e otimizar código para melhorar complexidade algorítmica, uso de memória, I/O e eficiência geral.

---

## PROCESSO DE OTIMIZAÇÃO

### Fase 1: Análise de Complexidade

1. Identificar complexidade algorítmica (Big-O) das funções principais
2. Detectar padrões O(n²) ou piores que podem ser otimizados
3. Verificar uso de estruturas de dados adequadas
4. Se necessário, carregar `[FULL:performance]` para regras detalhadas

### Fase 2: Otimizações

#### 2.1 Complexidade Algorítmica
```
ANTES: Loop aninhado O(n²) para busca
DEPOIS: HashMap O(1) para lookup
```

#### 2.2 Memory Management
- Identificar memory leaks potenciais
- Sugerir object pooling para alocações frequentes
- Otimizar uso de closures e event listeners

#### 2.3 I/O Optimization
- Detectar queries N+1 em ORMs
- Sugerir batch operations
- Recomendar connection pooling
- Identificar oportunidades de caching

#### 2.4 Caching
- Sugerir cache layers apropriados
- Implementar invalidação de cache
- Recomendar TTL adequado

### Fase 3: Validação

1. Verificar que otimizações não introduzem bugs
2. Confirmar que código segue princípios SOLID
3. Estimar ganho de performance

---

## OUTPUT FORMAT

```json
{
  "optimization_report": {
    "summary": "3 otimizações aplicadas, ganho estimado de 60%",
    "optimizations": [
      {
        "type": "algorithmic",
        "location": "services/search.py:15",
        "before": "O(n²) nested loop",
        "after": "O(n) with hash map",
        "estimated_improvement": "~80% for n > 100",
        "code_suggestion": "# Use dict comprehension for O(1) lookup\nindex = {item.id: item for item in items}"
      }
    ],
    "score": {
      "before": 45,
      "after": 82
    },
    "base_loaded": "code-standards-base@1.0.0 (summary)"
  }
}
```

---

## ERROR HANDLING

- Se `code-standards-base` não disponível: usar conhecimento interno, alertar usuário
- Se código vazio: retornar erro claro
- Se linguagem não reconhecida: tentar análise genérica, informar limitações

---

## IMPLEMENTS

Este skill implementa os métodos abstratos de `code-standards-base`:
- ✅ `optimize(code)` → Implementado (este skill)
- ⚠️ `audit(code)` → Delegado para `security-auditor`

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [gugastork](https://github.com/gugastork)
- **Source:** [gugastork/agente-skill-oop](https://github.com/gugastork/agente-skill-oop)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-gugastork-agente-skill-oop-performance-optimizer
- Seller: https://agentstack.voostack.com/s/gugastork
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
