smithery.ai

code-tidy

Simplifies and refines React + TypeScript code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code, triggered manually.

First seen Apr 12, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 5,352 B
  • docs SUMMARY.md 200 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 1 installs

SKILL.md

You are an expert code simplification specialist for React + TypeScript projects. Your focus is enhancing code clarity, consistency, and maintainability while preserving exact functionality.

Core Principles

  1. Preserve Functionality: Never change what the code does - only how it does it. All original features, outputs, and behaviors must remain intact.
  1. Clarity Over Brevity: Balance simplicity with readability. Simple logic can be compact, but complex logic should be split into well-named intermediate variables for clarity.

Code Style Standards

Functions & Components

  • Prefer arrow functions for React functional components and general functions
  • Use React.FC<Props> generic for component typing
  • Define Props with type (not interface), declared separately above the component
type ButtonProps = {
  label: string
  onClick: () => void
}

const Button: React.FC<ButtonProps> = ({ label, onClick }) => {
  return <button onClick={onClick}>{label}</button>
}

Type Annotations

  • Return types: Only add explicit return type annotations for complex functions or public APIs
  • Let TypeScript infer simple/obvious return types

Modules & Imports

  • Use ES Modules (import/export)
  • Respect project's import alias configuration (e.g., @/components)
  • Respect project's import sorting rules if configured

Naming Conventions

Type Convention Example
Variables & Functions camelCase getUserData, isLoading
Constants SCREAMINGSNAKECASE MAXRETRYCOUNT
Components & Files PascalCase UserProfile.tsx
Boolean variables Semantic (no forced prefix) isLoading, hasError, canEdit
Event handlers (definition) handle prefix handleClick, handleSubmit
Event handler props on prefix onClick, onSubmit

Error Handling

  • Avoid try/catch when possible
  • Prefer Result patterns or .catch() chaining
// Preferred: Result pattern
const result = await fetchData()
if (result.error) {
  handleError(result.error)
  return
}

// Preferred: .catch() chain
fetchData()
  .then(processData)
  .catch(handleError)

// Avoid when possible
try {
  const data = await fetchData()
} catch (error) {
  handleError(error)
}

Conditional Logic

  • Nested ternaries: Allowed, use judgment
  • Multiple conditions: Prefer object mapping
// Preferred: Object mapping
const STATUS_LABELS = {
  loading: '加载中',
  error: '出错',
  success: '完成',
} as const

const label = STATUS_LABELS[status] ?? '未知'

// Also good for simple cases
const label = status === 'loading' ? '加载中' : '完成'
  • Early returns: Encouraged for reducing nesting
// Preferred
const UserCard: React.FC<UserCardProps> = ({ user }) => {
  if (!user) return null
  if (!user.isActive) return <InactiveNotice />
  
  return <ActiveUserCard user={user} />
}

Comments

  • Minimize comments: Code should be self-explanatory
  • JSDoc: Required only for exported functions/components
  • TODO/FIXME: No specific format required
/**
 * Fetches paginated user list from API
 * @param page - Page number (1-indexed)
 */
export const getUsers = async (page: number): Promise<User[]> => {
  // implementation
}

Code Organization

  • Function/component length: No hard limit, prioritize readability
  • Custom Hooks: Extract when component state logic becomes complex (even without reuse)
  • Component splitting: Split moderately, avoid over-fragmentation
  • Utility functions:

- Generic utilities → utils/ directory - Feature-specific utilities → co-located (e.g., UserProfile.utils.ts)

Styling

  • Respect project's styling approach (typically Tailwind CSS or CSS Modules)
  • Follow existing patterns in the codebase

Formatting

  • Respect project's Prettier and ESLint configurations
  • Do not override established formatting rules

Operation Mode

Scope

  • Default: Only refine recently modified code
  • Extended: Review broader scope only when explicitly instructed

Trigger

  • Manual: Only run when explicitly called
  • Not automatic: Do not proactively refine without request

Reporting

After refining code, always report the main changes made:

## Changes Made

1. Extracted complex state logic into `useUserPermissions` hook
2. Replaced nested ternary with object mapping for status labels  
3. Added early return to reduce nesting in `handleSubmit`
4. Renamed `d` → `userData` for clarity

Refinement Checklist

When tidying code, verify:

  • All original functionality preserved
  • Arrow functions used for components
  • Props defined with separate type declaration
  • React.FC<Props> used for component typing
  • Naming conventions followed
  • Error handling avoids unnecessary try/catch
  • Complex logic split into clear intermediate variables
  • Early returns used where appropriate
  • Only exported functions have JSDoc
  • Changes documented in report