跳到正文
cccskills
免费在 GitHub 公开

learn-alternatives

Compare alternative ways to solve a coding problem, including when each approach fits and its advantages and drawbacks. Get a comparison table and a recommendation based on the current context, with code examples in detailed mode.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Compare different approaches to solve the same problem

查看安装方法

适用场景

  • Compare authentication approaches
  • Choose how to manage form state
  • Evaluate data fetching or styling options
  • Review alternatives with code examples

包含的文件(1)

  • SKILL.md4.9 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Show alternatives

Compare different approaches to solve the same problem.

Usage

/learn:alternatives              # Compare approaches for current code
/learn:alternatives auth         # Compare authentication methods
/learn:alternatives state        # Compare state management options
/learn:alternatives --detailed   # Include code examples for each

Instructions

  1. Identify the problem being solved (from context or argument)
  2. Present 3-5 alternative approaches
  3. For each approach, explain:
    • What it is (one sentence)
    • When to use it
    • Trade-offs (pros/cons)
  4. Provide a recommendation based on context
  5. Optionally show code examples for top choices

Response format

## Problem: [What we're trying to solve]

### Approach 1: [Name]

**What**: [One-sentence description]

**When to use**:
- [Scenario 1]
- [Scenario 2]

**Pros**: [List]
**Cons**: [List]

---

### Approach 2: [Name]
...

---

## Comparison Table

| Criteria | Approach 1 | Approach 2 | Approach 3 |
|----------|------------|------------|------------|
| Complexity | Low | Medium | High |
| Performance | ★★☆ | ★★★ | ★★☆ |
| Bundle size | Small | Medium | Large |
| Learning curve | Easy | Medium | Steep |

## Recommendation

**For your case**: [Recommended approach] because [reason based on context]

**Consider instead if**: [Alternative scenarios]

Comparison criteria

Standard criteria to evaluate (adjust based on problem):

CriteriaDescription
ComplexityHow hard to implement and maintain
PerformanceRuntime speed, memory usage
Bundle sizeImpact on frontend bundle
Learning curveTime to understand and use correctly
FlexibilityEase of extending or modifying
CommunityDocumentation, ecosystem, support
TestingHow easy to test
Type safetyTypeScript support quality

Depth modes

Default

  • 3-4 alternatives
  • Brief description each
  • Comparison table
  • Recommendation

--detailed

  • 4-5 alternatives
  • Code example for each
  • Detailed trade-offs
  • Migration considerations
  • Real-world case studies

--quick

  • 2-3 alternatives
  • One-line each
  • Quick recommendation

Example session

User: I'm using useState for form state. /learn:alternatives

Claude: ## Problem: Managing Form State in React

### Approach 1: Multiple useState

**What**: Separate useState for each field

**When to use**:
- Simple forms (< 5 fields)
- No complex validation
- No cross-field dependencies

**Pros**: Simple, no dependencies, easy to understand
**Cons**: Verbose with many fields, scattered state

---

### Approach 2: Single useState with Object

**What**: One useState holding all fields as object

**When to use**:
- Medium forms (5-10 fields)
- Need to reset entire form
- Want cleaner code

**Pros**: Grouped state, easy reset, cleaner
**Cons**: Need spread operator, can cause unnecessary re-renders

---

### Approach 3: useReducer

**What**: Reducer pattern for complex state transitions

**When to use**:
- Complex validation logic
- Multi-step forms
- Undo/redo functionality

**Pros**: Predictable updates, handles complex logic, testable
**Cons**: More boilerplate, learning curve

---

### Approach 4: Form Library (React Hook Form, Formik)

**What**: Dedicated form state management library

**When to use**:
- Large forms (10+ fields)
- Complex validation (async, cross-field)
- Performance critical (many fields)

**Pros**: Optimized re-renders, validation built-in, less code
**Cons**: Dependency, learning curve, bundle size

---

## Comparison Table

| Criteria | useState | useReducer | React Hook Form |
|----------|----------|------------|-----------------|
| Complexity | Low | Medium | Medium |
| Performance | ★★☆ | ★★☆ | ★★★ |
| Bundle size | 0kb | 0kb | ~8kb |
| Validation | Manual | Manual | Built-in |
| Best for | Simple | Complex logic | Large forms |

## Recommendation

**For your case**: If this is a simple login/contact form, stick with **useState**. If you're building a multi-step checkout or admin form, consider **React Hook Form** for the validation and performance benefits.

**Consider useReducer if**: You need undo/redo, complex state machines, or want reducer-style testing.

Common alternative comparisons

TopicTypical Alternatives
StateuseState, useReducer, Zustand, Redux, Jotai
StylingCSS Modules, Tailwind, styled-components, CSS-in-JS
Data fetchingfetch, axios, React Query, SWR
FormsuseState, React Hook Form, Formik
AuthJWT, sessions, OAuth, magic links
API designREST, GraphQL, tRPC, gRPC
TestingJest, Vitest, Testing Library, Cypress
DatabasesPostgreSQL, MySQL, MongoDB, SQLite

$ARGUMENTS

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Evaluate Claude Code agents, skills, and commands with weighted quality criteria. Get scores, readiness grades, template comparisons, and practical improvement suggestions in Markdown or JSON reports to guide reviews before release.

中文简介正在准备中。当前显示英语简介。

  • Review skills before release
  • Compare agent definitions with reference templates
  • Quickly check critical quality criteria
FlorianBruniaux/claude-code-ultimate-guide62072026年10月20日 更新

Assess a codebase across seven areas, including exposed credentials, security, dependencies, structure, and tests. Receive category scores, findings tied to file locations, and a prioritized improvement plan with smaller tasks that can be completed quickly.

中文简介正在准备中。当前显示英语简介。

  • Assessing the overall health of an inherited project
  • Reviewing exposed credentials and security risks
  • Identifying dependency and test coverage gaps
FlorianBruniaux/claude-code-ultimate-guide62072026年10月20日 更新

Measure code patterns such as casts to any or disabled lint rules, then run repeated, targeted edits. Keep changes that improve the chosen metric, revert unsuccessful changes, and track results for each improvement loop.

中文简介正在准备中。当前显示英语简介。

  • Finding code patterns to prioritize for cleanup
  • Preparing measurement files for an improvement loop
  • Repeating targeted edits to reduce casts to any
FlorianBruniaux/claude-code-ultimate-guide62072026年10月20日 更新

best-of-n

免费

Generate several separate solutions, compare them against criteria fixed in advance, and verify the selected result through executable checks or an independent reviewer. Keep a proof log documenting candidates, evidence, failures, and remaining limits.

中文简介正在准备中。当前显示英语简介。

  • Comparing implementation options before choosing one
  • Verifying a solution when a wrong choice would be costly
  • Keeping evaluation evidence for delivery or audit
FlorianBruniaux/claude-code-ultimate-guide62072026年10月20日 更新

canary

免费

Monitor a live application after deployment and compare it with a saved baseline, a record of its earlier state. Check page responses, loading times, and new errors, flag persistent changes, and produce a per-page health report.

中文简介正在准备中。当前显示英语简介。

  • Recording a healthy baseline before deployment
  • Monitoring production immediately after deployment
  • Checking key pages for slower responses or failures
FlorianBruniaux/claude-code-ultimate-guide62072026年10月20日 更新

catchup

免费

Rebuild project context after clearing a conversation or returning to work. Review recent Git history, uncommitted changes, and TODO markers to get a structured summary of project status and suggested next steps.

中文简介正在准备中。当前显示英语简介。

  • Restoring project context after /clear
  • Reviewing recent changes after a long break
  • Checking unfinished work before choosing the next task
FlorianBruniaux/claude-code-ultimate-guide62072026年10月20日 更新

查看 FlorianBruniaux 的全部技能

报告此技能的问题