optimize

A code and database performance review command. It looks for patterns that can make an application slower, such as repeated database queries inside loops or queries that scan too much data.

In plain words
What is it for?
Use it to analyze the whole project or a selected domain, check for N+1 queries, missing indexes, overly broad transactions, and inefficient data fetching, with an optional automatic-fix mode.
Why use it?
It helps locate common sources of slow response times and expensive database work. It can either report recommendations or apply fixes when requested.

Skill for Claude CodeCodex

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 skills/demodev-lab/claude-code-plugin-demokit/optimize
Any agent
npx skills add demodev-lab/claude-code-plugin-demokit --skill optimize
Clone the repo
git clone --depth 1 https://github.com/demodev-lab/claude-code-plugin-demokit

Made for: Claude Code, Codex.

Per session 59 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,306 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.00059 $0.01306
Opus 5 $0.00030 $0.00653
Sonnet 5 $0.00012 $0.00261
Haiku 4.5 $0.00006 $0.00131

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

Security

Grade A, and why

optimize 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.

skills/optimize/SKILL.md · 148 lines

How it starts

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

/optimize - 성능 최적화 분석

help

인자가 help이면 아래 도움말만 출력하고 실행을 중단한다:

/optimize — 성능 최적화 분석 및 개선

사용법:
  /optimize [target] [--fix]

파라미터:
  target  최적화 대상 (선택, 기본 전체)
          도메인명, 파일경로, all
  --fix   분석 후 자동 수정 (선택, 기본 분석만)

예시:
  /optimize              — 전체 분석
  /optimize User         — User 도메인 최적화
  /optimize User --fix   — User 도메인 분석 + 자동 수정

관련 명령:
  /review   — 코드 리뷰
  /qa       — 동적 품질 검증
  /erd      — ERD 다이어그램

심각도 기준

🔴 Critical — 즉시 수정 (N+1 쿼리, 누락 인덱스로 인한 풀스캔) 🟡 Warning — 수정 권장 (트랜잭션 범위 과다, readOnly 누락) 🟢 Info — 선택적 개선 (Projection 최적화, 페이징 개선)

실행 절차

담당 에이전트: domain-expert (코드 레벨) + dba-expert (DB 레벨, 병렬)

1단계: 프로젝트 스캔

  • Entity, Repository, Service 파일 전체 수집
  • application.yml JPA 설정 확인

체크포인트: [1/6 완료: 프로젝트 스캔]

병렬 분석 (Task A + Task B 동시 실행)

Task A (domain-expert):

2단계: N+1 문제 분석

다음 패턴을 탐지:

  • Entity: @OneToMany/@ManyToMany 없이 FetchType.LAZY 미지정
  • Repository: findAll() 후 연관 Entity 접근 패턴
  • Service: 루프 내 findBy* 호출
  • QueryDSL: fetchJoin() 미사용

출력:

[N+1] User.orders — @OneToMany without FetchType.LAZY
  해결: fetch = FetchType.LAZY + @BatchSize(size = 100)
  또는: @EntityGraph(attributePaths = {"orders"})

체크포인트: [2/6 완료: N+1 분석]

4단계: 트랜잭션 분석
  • @Transactional 범위 확인 (불필요하게 넓은 범위)
  • 읽기 전용 메서드에 @Transactional(readOnly = true) 미적용
  • Controller에 @Transactional 사용 여부

출력:

[Transaction] UserService.getUser() — readOnly = true 누락
  해결: @Transactional(readOnly = true) 추가

체크포인트: [4/6 완료: 트랜잭션 분석]

Task B (dba-expert):

3단계: 인덱스 분석
  • @Query/QueryDSL에서 WHERE 조건 컬럼 추출
  • findBy* 쿼리 메서드의 조건 컬럼 분석
  • 복합 인덱스 필요 여부 판단

출력:

[인덱스] Order.userId + Order.status — 복합 인덱스 권장
  @Table(indexes = @Index(name = "idx_order_user_status", columnList = "user_id, status"))

체크포인트: [3/6 완료: 인덱스 분석]

5단계: 쿼리 최적화
  • SELECT * 대신 필요한 컬럼만 Projection
  • 불필요한 Entity 전체 로드
  • 페이징 없는 대량 조회

체크포인트: [5/6 완료: 쿼리 최적화]

6단계: 결과 보고서

두 Task 결과를 통합하여 보고서 생성:

## 성능 최적화 보고서

| 카테고리 | 심각도 | 건수 |
|----------|--------|------|
| N+1 문제 | 🔴 Critical | N건 |
| 인덱스 누락 | 🔴 Critical | N건 |
| 트랜잭션 범위 | 🟡 Warning | N건 |
| 쿼리 최적화 | 🟢 Info | N건 |

### 상세 내역
(각 항목별 문제-해결 방안)

Read the full file on GitHub · 148 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 148 lines · 59 tokens per session scan A 563cabe0a558

Subscribe to this mod's changes

optimize is a skill published in the GitHub repository demodev-lab/claude-code-plugin-demokit (2 stars, last pushed 6mo ago), licensed MIT. It adds 59 tokens to every session and 1,306 once invoked, about $0.0003 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-31.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens