Dorothy: Skill for Claude Code

.agents/skills/component-refactoring/SKILL.md

component-refactoring is a skill for Claude Code, Codex from Charlie85270/Dorothy. It costs 93 tokens per session (3,490 once invoked), scanned A, a copy of component-refactoring, MIT.

A guide for breaking up overly complex React components in Dify, a software application with a React frontend. It covers extracting hooks, splitting code, and reducing component size and complexity.

In plain words
What is it for?
Use it when Dify's analysis reports high complexity or more than 300 lines, or when the user asks to split or simplify a component before testing.
Why use it?
It provides a consistent way to handle components that are difficult to understand, test, or maintain.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents).

This is Charlie85270/Dorothy's own configuration. It tells Claude Code and Codex how to work on Dorothy itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything Dorothy configures →

Reuse

Borrowing it

Nothing to install: this file belongs to Charlie85270/Dorothy. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/Charlie85270/Dorothy/main/.agents/skills/component-refactoring/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/Charlie85270/Dorothy

Made for: Claude Code, Codex.

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 component-refactoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/charlie85270/dorothy/component-refactoring/github.svg)](https://agentmods.dev/skills/charlie85270/dorothy/component-refactoring)
Your own site
<a href="https://agentmods.dev/skills/charlie85270/dorothy/component-refactoring"><img src="https://agentmods.dev/badge/skills/charlie85270/dorothy/component-refactoring/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 component-refactoring

Your own site · 80×15
<a href="https://agentmods.dev/skills/charlie85270/dorothy/component-refactoring"><img src="https://agentmods.dev/badge/skills/charlie85270/dorothy/component-refactoring.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 93 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,490 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 100% copy Near-identical to another mod 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.00093 $0.03490
Opus 5 $0.00046 $0.01745
Sonnet 5 $0.00019 $0.00698
Haiku 4.5 $0.00009 $0.00349

Measured 9d ago against content hash c9305b49807a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

component-refactoring 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 9d 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.

Origin

This is a copy

100% identical to component-refactoring — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.agents/skills/component-refactoring/SKILL.md · 484 lines

How it starts

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

Dify Component Refactoring Skill

Refactor high-complexity React components in the Dify frontend codebase with the patterns and workflow below.

Complexity Threshold: Components with complexity > 50 (measured by pnpm analyze-component) should be refactored before testing.

Quick Reference

Commands (run from web/)

Use paths relative to web/ (e.g., app/components/...). Use refactor-component for refactoring prompts and analyze-component for testing prompts and metrics.

cd web

# Generate refactoring prompt
pnpm refactor-component <path>

# Output refactoring analysis as JSON
pnpm refactor-component <path> --json

# Generate testing prompt (after refactoring)
pnpm analyze-component <path>

# Output testing analysis as JSON
pnpm analyze-component <path> --json

Complexity Analysis

# Analyze component complexity
pnpm analyze-component <path> --json

# Key metrics to check:
# - complexity: normalized score 0-100 (target < 50)
# - maxComplexity: highest single function complexity
# - lineCount: total lines (target < 300)

Complexity Score Interpretation

Score Level Action
0-25 🟢 Simple Ready for testing
26-50 🟡 Medium Consider minor refactoring
51-75 🟠 Complex Refactor before testing
76-100 🔴 Very Complex Must refactor

Core Refactoring Patterns

Pattern 1: Extract Custom Hooks

When: Component has complex state management, multiple useState/useEffect, or business logic mixed with UI.

Dify Convention: Place hooks in a hooks/ subdirectory or alongside the component as use-<feature>.ts.

// ❌ Before: Complex state logic in component
const Configuration: FC = () => {
  const [modelConfig, setModelConfig] = useState<ModelConfig>(...)
  const [datasetConfigs, setDatasetConfigs] = useState<DatasetConfigs>(...)
  const [completionParams, setCompletionParams] = useState<FormValue>({})
  
  // 50+ lines of state management logic...
  
  return <div>...</div>
}

// ✅ After: Extract to custom hook
// hooks/use-model-config.ts
export const useModelConfig = (appId: string) => {
  const [modelConfig, setModelConfig] = useState<ModelConfig>(...)
  const [completionParams, setCompletionParams] = useState<FormValue>({})
  
  // Related state management logic here
  
  return { modelConfig, setModelConfig, completionParams, setCompletionParams }
}

// Component becomes cleaner
const Configuration: FC = () => {
  const { modelConfig, setModelConfig } = useModelConfig(appId)
  return <div>...</div>
}

Read the full file on GitHub · 484 lines

Files

What ships with it

3 files 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. 9d ago First seen · 484 lines · 93 tokens per session scan A c9305b49807a

Subscribe to this mod's changes

component-refactoring is a skill published in the GitHub repository Charlie85270/Dorothy (345 stars, last pushed 2mo ago), licensed MIT. It adds 93 tokens to every session and 3,490 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to component-refactoring, differing in 0 lines, and is treated as a copy.

Related

Other skills, from other repositories

frontend

UI implementation, components, accessibility. Use when frontend, ui, ux, interface, client, componentes. Always apply engineering-reuse first.

Mazalucas/El-DT-Lightweight-Army · 30 tokens

trigger-realtime-and-frontend

Trigger.dev client/frontend surface: subscribe to runs in realtime (runs.subscribeToRun and the @trigger.dev/react-hooks hook useRealtimeRun), consume metadata and AI/text streams in React (useRealtimeStream), trigger tasks from the browser (useTaskTrigger, useRealtimeTaskTrigger), and mint scoped frontend credentials…

triggerdotdev/trigger.dev · 148 tokens

react-modern

Use this skill when writing or reviewing React 19+ code in WrongStack. Triggers: user mentions "React", "component", "useState", "useEffect", "Server Component", "Client Component", "Suspense", "useTransition", "use hook".

WrongStack/WrongStack · 57 tokens

react-artifact

Author app-like designs in React/JSX and bundle them in-sandbox into the same single self-contained HTML artifact Design Studio delivers. Use when the design needs real state, complex interactivity, or component reuse beyond what vanilla JS comfortably handles.

juspay/xyne-spaces · 53 tokens

generic-react-feature-developer

Guide feature development for React applications with architecture focus. Covers Zustand/Redux patterns, IndexedDB usage, component systems, lazy loading strategies, and seamless integration. Use when adding new features, refactoring existing code, or planning major changes.

travisjneuman/.claude · 53 tokens

generic-react-ux-designer

Professional UI/UX design expertise for React applications. Covers design thinking, user psychology (Hick's/Fitts's/Jakob's Law), visual hierarchy, interaction patterns, accessibility, performance-driven design, and design critique. Use when designing features, improving UX, solving user problems, or conducting design…

travisjneuman/.claude · 69 tokens