fp-refactor
它能做什么
这个工具可以借助 fp-ts 库,把 TypeScript 中命令式(imperative)风格的代码改写成函数式编程风格。它还提供了一份完整的迁移指南。
适用场景
- ✓当你想把现有的 TypeScript 代码重构为 fp-ts 的函数式模式时。
- ✓当你需要把 `try/catch`、null 检查、回调或循环等代码块转换成函数式写法时。
- ✓当你需要迁移指导和权衡取舍的说明,而不只是孤立的示例时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-refactor/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想把命令式的 TypeScript 代码改写成 fp-ts 的函数式模式,其中包括 try/catch 和 null 检查的转换,该怎么做?”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会分析你的 TypeScript 代码,并应用 fp-ts 库中的函数式编程模式。它会指导你用函数式写法替换命令式结构,比如用 `Either` 处理错误,用 `Option` 处理可选值。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Refactoring Imperative Code to fp-ts
This skill provides comprehensive patterns and strategies for migrating existing imperative TypeScript code to fp-ts functional programming patterns.
Detailed Guide
Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.
When to Use
- You are refactoring an existing imperative TypeScript codebase toward fp-ts patterns.
- The task involves converting
try/catch, null checks, callbacks, DI, or loops into functional equivalents. - You need migration guidance and tradeoffs, not just isolated fp-ts examples.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
常见问题
什么是函数式编程?
它是一种编程风格,把计算看作数学函数的求值过程,并避免改变状态和可变数据。
什么是 fp-ts?
它是一个用于 TypeScript 的库,把函数式编程的优势带入这门语言,提供了一些类型和函数,帮助你编写更健壮、表达力更强的代码。
什么是命令式代码?
它是一种编程风格,通过一步一步的指令描述程序应该如何改变自身的状态。
详情
作者的原始描述
Comprehensive guide for refactoring imperative TypeScript code to fp-ts functional patterns
热度
- GitHub 星标
- 48k
- 排名
- #4647
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。