fdk-refactor

fdk-refactor is a command for Claude Code from freshworks-developers/fw-dev-tools. It costs 41 tokens per session (539 once invoked), scanned A, original, MIT.

A code-refactoring command for Freshworks apps that makes complicated functions easier to follow while keeping their behavior unchanged. It targets a maximum cyclomatic complexity of 7, a measure of how many independent decision paths code has.

In plain words
What is it for?
Use it to find complex functions in a Freshworks app and split, simplify, or reorganize them without changing what the app does.
Why use it?
It reduces deeply nested logic, long functions, and large chains of conditions that make code harder to test and maintain.

Command for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the fw-app-dev plugin — 1 skill, 5 commands, 3 agents shipped together

Good fit Use it to find complex functions in a Freshworks app and split, simplify, or reorganize them without changing what the app does.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/freshworks-developers/fw-dev-tools/fdk-refactor
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.

Clone the repo
git clone --depth 1 https://github.com/freshworks-developers/fw-dev-tools

Made for: Claude Code.

Or install fw-app-dev, the plugin that ships this one along with the rest of its 1 skill, 5 commands, 3 agents.

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 fdk-refactor

README.md
[![agentmods](https://agentmods.dev/badge/commands/freshworks-developers/fw-dev-tools/fdk-refactor/github.svg)](https://agentmods.dev/commands/freshworks-developers/fw-dev-tools/fdk-refactor)
Your own site
<a href="https://agentmods.dev/commands/freshworks-developers/fw-dev-tools/fdk-refactor"><img src="https://agentmods.dev/badge/commands/freshworks-developers/fw-dev-tools/fdk-refactor/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 fdk-refactor

Your own site · 80×15
<a href="https://agentmods.dev/commands/freshworks-developers/fw-dev-tools/fdk-refactor"><img src="https://agentmods.dev/badge/commands/freshworks-developers/fw-dev-tools/fdk-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 41 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 539 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.00041 $0.00539
Opus 5.5 $0.00016 $0.00216
Sonnet 5.5 $0.00008 $0.00108
Haiku 4.5 $0.00004 $0.00054

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

Security

Grade A, and why

fdk-refactor 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 1mo 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.

skills/fw-app-dev/commands/fdk-refactor.md · 54 lines

What it actually says

FDK Refactor Command

Usage: /fdk-refactor

You are reducing function complexity in a Freshworks app. Target: cyclomatic complexity ≤ 7 per function. Follow these steps exactly.

Step 1: Determine app directory

  1. Search the workspace for manifest.json files.
  2. If multiple folders contain manifest.json: Ask the user which app to refactor.
  3. If one folder: Use that directory.
  4. If none: Inform the user and stop.

Step 2: Identify high-complexity functions

Scan server/server.js and app/scripts/*.js for functions with:

  • Deep nesting (multiple if/for/while levels)
  • Many conditional branches
  • Long functions (> 50 lines)

Reference: Code complexity threshold is 7 (max cyclomatic complexity per function).

Step 3: Refactoring techniques

Apply these patterns:

  1. Extract helper functions: Move nested logic into separate, well-named functions.
  2. Early returns: Replace nested ifs with guard clauses.
  3. Extract loops: Move loop bodies into separate functions.
  4. Simplify conditionals: Use lookup tables or strategy pattern instead of long if-else chains.

Step 4: Preserve behavior

  • Do NOT change app behavior or logic.
  • Keep helper functions after the exports block (FDK parser requirement).
  • Ensure all exports still work correctly.

Step 5: Validate

First: SKILL.md → Manifest + toolchain gate before any fdk validate (same as /fdk-fix: fw-setup / /fdk-migrate / raise engines — no toolchain downgrade).

Toolchain: If fdk validate cannot run, fw-app-dev does not install the CLI — use fw-setup or prompt the user to add it (SKILL.md → FDK / Node.js toolchain — not provided by fw-app-dev).

Run: cd <app-directory> && fdk validate

Ensure no new errors were introduced. Report the refactored functions and validation status.

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. 1mo ago First seen · 54 lines · 41 tokens per session scan A b138c20ff52d

Subscribe to this mod's changes

fdk-refactor is a command published in the GitHub repository freshworks-developers/fw-dev-tools (5 stars, last pushed 25d ago), licensed MIT. It adds 41 tokens to every session and 539 once invoked, about $0.0002 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.