replace-temp-with-query

replace-temp-with-query is a skill for Claude Code from msbaek/msbaek-claude-plugins. It costs 98 tokens per session (1,185 once invoked), scanned A, original, MIT.

A refactoring method that replaces a temporary variable with a method call that provides the same value.

In plain words
What is it for?
Use it to remove unnecessary temporary variables, reduce duplication, and make calculations clearer.
Why use it?
Temporary variables can duplicate logic and make a method harder to read when the value is only used to express a calculation.

Skill for Claude Code

Written for Claude Code: argument-hint in frontmatter.

Part of the msbaek-tdd plugin — 28 skills, 10 agents, 2 hooks shipped together

Good fit Use it to remove unnecessary temporary variables, reduce duplication, and make calculations clearer.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/msbaek/msbaek-claude-plugins/replace-temp-with-query
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.

Any agent
npx skills add msbaek/msbaek-claude-plugins --skill replace-temp-with-query
Clone the repo
git clone --depth 1 https://github.com/msbaek/msbaek-claude-plugins

Made for: Claude Code.

Or install msbaek-tdd, the plugin that ships this one along with the rest of its 28 skills, 10 agents, 2 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for replace-temp-with-query

README.md
[![agentmods](https://agentmods.dev/badge/skills/msbaek/msbaek-claude-plugins/replace-temp-with-query/github.svg)](https://agentmods.dev/skills/msbaek/msbaek-claude-plugins/replace-temp-with-query)
Your own site
<a href="https://agentmods.dev/skills/msbaek/msbaek-claude-plugins/replace-temp-with-query"><img src="https://agentmods.dev/badge/skills/msbaek/msbaek-claude-plugins/replace-temp-with-query/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for replace-temp-with-query

Your own site · 80×15
<a href="https://agentmods.dev/skills/msbaek/msbaek-claude-plugins/replace-temp-with-query"><img src="https://agentmods.dev/badge/skills/msbaek/msbaek-claude-plugins/replace-temp-with-query.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 98 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,185 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00098 $0.01185
Opus 5.5 $0.00039 $0.00474
Sonnet 5.5 $0.00020 $0.00237
Haiku 4.5 $0.00010 $0.00119

Measured 2mo ago against content hash 19a183916afd, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

replace-temp-with-query 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 2mo ago.

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.

msbaek-tdd/skills/replace-temp-with-query/SKILL.md · 133 lines

How it starts

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

Replace Temp with Query

GOAL

한 번만 대입되고 여러 곳에서 사용되는 임시 변수를 의미 있는 이름의 메서드로 추출하여:

  • 중복된 계산 로직 제거
  • 표현식의 의미를 명확한 메서드명으로 전달
  • Extract Method의 전제 조건 충족 (임시 변수 제거)

CONSTRAINTS

  • 계열: Tidy — 후보 보고 후 승인 없이 적용 (../../references/refactoring-procedure.md §0·§3-A)
  • 동작 변경 금지: 구조 개선만 수행 (기능 변경 없음)
  • 테스트 수정 금지: 구조 변경이 테스트를 실패시키면 되돌리기
  • 명시적 git add: git add -A 금지, 변경된 파일만 명시

적용 패턴

Before

double basePrice = quantity * itemPrice;
if (basePrice > 1000) {
    return basePrice * 0.95;
} else {
    return basePrice * 0.98;
}

After

if (basePrice() > 1000) {
    return basePrice() * 0.95;
} else {
    return basePrice() * 0.98;
}

private double basePrice() {
    return quantity * itemPrice;
}

추가 예시: 복잡한 조건식

// Before
double tax = order.getTotal() * 0.1;
double shipping = order.getTotal() > 100 ? 0 : 10;
return order.getTotal() + tax + shipping;

// After
return order.getTotal() + tax() + shipping();

private double tax() { return order.getTotal() * 0.1; }
private double shipping() { return order.getTotal() > 100 ? 0 : 10; }

적용 기준

적용 대상

  • 한 번만 대입되는 임시 변수
  • 여러 곳에서 참조되는 변수
  • 복잡한 표현식을 담은 변수 (의미 부여 가치 높음)
  • Extract Method 전 단계로 사용

적용 제외

  • 루프 내 누적 변수 (accumulator): sum += value;
  • 부수효과 있는 표현식: 메서드 호출이 상태 변경하는 경우
  • 여러 번 대입되는 변수: 값이 변경되는 경우
  • 성능 크리티컬 구간: 측정된 성능 문제가 있는 경우만

OUTPUT FORMAT

실행 절차

공통 골격(대상 파일 수집 → 후보 제시(계열별 승인 규칙) → 적용 → 테스트 → 커밋/되돌리기, 브랜치·PR이 필요한 조건)은 이 스킬 디렉터리 기준 ../../references/refactoring-procedure.md가 정본이다. 아래는 이 기법에 고유한 부분만 규정한다.

후보 식별 (공통 절차 2단계)
  • 임시 변수 패턴 탐지 (한 번 대입, 여러 번 참조)
  • 적용 제외 조건 필터링
  • 각 후보에 대해:
    • 파일명 및 라인 번호
    • Before/After 코드 미리보기
    • 적용 근거 (참조 횟수, 표현식 복잡도)
후보 제시 예시 (공통 절차 3단계)
발견된 후보 3개:

1. OrderService.java:45
   basePrice = quantity * itemPrice
   → private double basePrice() { return quantity * itemPrice; }
   (참조 3회, 복잡도 낮음)

→ 승인 없이 적용 (Tidy 계열)
리팩토링 적용 (공통 절차 4단계)
  • 메서드 추출 (private, 원본 표현식)
  • 임시 변수 참조를 메서드 호출로 치환
  • 임시 변수 선언 제거

Read the full file on GitHub · 133 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. 2mo ago Changed · -1 lines · +63 tokens per session 19a183916afd
  2. 2mo ago Changed 413875667b5a
  3. 3mo ago First seen · 134 lines · 35 tokens per session scan A 6863dd4f6efb

Subscribe to this mod's changes

replace-temp-with-query is a skill published in the GitHub repository msbaek/msbaek-claude-plugins (8 stars, last pushed 1mo ago), licensed MIT. It adds 98 tokens to every session and 1,185 once invoked, about $0.0004 per session on Opus 5.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

replace-temp-with-query compared with skills from other repositories

replace-temp-with-query next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
replace-temp-with-querymsbaek/msbaek-claude-pluginsSkill81mo agoMITA98Claude Code
systematic-debuggingopen-metadata/OpenMetadataSkill16ktodayApache-2.0A37Claude Code
log-error-digestzebbern/claude-code-guideSkill4.7ktodayMITA71Claude Code, Codex
observability-audit-sessionsIBM/mcp-context-forgeSkill4.9ktodayApache-2.0A64Claude Code, Codex
cwv-optimizeradobe/skillsSkill343todayApache-2.0A112Claude Code
performance-verificationvalkor-ai/loomSkill1.6k3d agoApache-2.0A45Claude Code, Codex
loop-engineeringhuytieu/COG-second-brainSkill1.6kyesterdayMITA63Claude Code