本文へ移動
cccskills
無料GitHub で公開

functional

Refactor Swift code toward declarative functional programming with immutability, value types, pure functions, transformations, and closure-based APIs. Use when asked for functional refactoring or `/refactor:functional`.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md2.8 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Refactor this Swift codebase to follow functional programming principles:

Replace Mutability with Immutability

Convert var to let wherever possible Replace mutable collections with immutable transformations Use value types (structs/enums) instead of reference types (classes) where appropriate Eliminate property mutations in favor of creating new instances

Extract Pure Functions

Identify functions with side effects and refactor them to be pure Move I/O operations (network calls, file access, database queries) to the edges of the system Replace stateful methods with functions that take input and return output Ensure functions don't modify external state or rely on mutable global variables

Use Higher-Order Functions

Replace for-loops with map, filter, reduce, compactMap, flatMap Convert imperative conditional logic to functional chains Use function composition to build complex operations from simple ones Leverage lazy sequences for performance where appropriate

Functional Error Handling

Replace try-catch blocks with Result types where suitable Use Optional chaining and nil-coalescing operators Implement functional error propagation with map and flatMap on Result Avoid force unwrapping (!); use guard let, if let, or functional alternatives

Eliminate Shared Mutable State

Replace singletons with dependency injection of immutable services Convert stateful classes to stateless functions or immutable structs Use actors or other concurrency-safe patterns when mutation is necessary Pass data explicitly rather than relying on shared state

Apply Functional Patterns

Implement custom operators for common transformations Use currying for partial function application Create small, composable functions following the single responsibility principle Model domain concepts as algebraic data types (enums with associated values)

Specific Transformations

Convert delegate patterns to closure-based APIs Replace inheritance hierarchies with protocol composition Transform imperative algorithms to recursive or fold-based implementations Use KeyPaths for type-safe property access

Example transformation patterns to look for:

Loops that build arrays → map/filter/reduce Nested if-else → pattern matching with switch Mutable accumulator patterns → fold/reduce Callback hell → flatMap chains or async/await Stateful iteration → sequence/generator patterns

Maintain Swift idioms while applying functional principles. The goal is readable, maintainable code that leverages Swift's functional capabilities without sacrificing clarity.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

日本語の概要は準備中です。原文の説明を表示しています。

SDiamante13/dotfiles82026年10月2日 更新

catchup

無料

Rebuilds session context after a clear by reading git history, plans, and beads state. Triggers on 'catch up'.

日本語の概要は準備中です。原文の説明を表示しています。

SDiamante13/dotfiles82026年10月2日 更新

changelog

無料

Generate a bullet-point summary of branch changes for a PR description. Triggers on "changelog", "pr summary", "summarize branch", or "/changelog".

日本語の概要は準備中です。原文の説明を表示しています。

SDiamante13/dotfiles82026年10月2日 更新

commit

無料

Commit the current changes with quality checks, status review, staged diff inspection, appropriate tests, and a clear commit message. Use when the user says "commit", "c", asks to make a commit, or wants changes saved in git.

日本語の概要は準備中です。原文の説明を表示しています。

SDiamante13/dotfiles82026年10月2日 更新

declutter

無料

Refactor code to remove dead code, useless comments, unused variables, and unused imports. Use when asked to declutter a class, clean up noisy code, remove cruft, or run `/refactor:declutter`.

日本語の概要は準備中です。原文の説明を表示しています。

SDiamante13/dotfiles82026年10月2日 更新

dry

無料

Refactor duplicated code by extracting helpers, shared abstractions, or clearer reusable structure. Use when asked to apply DRY, remove duplication, consolidate repeated logic, or run `/refactor:dry`.

日本語の概要は準備中です。原文の説明を表示しています。

SDiamante13/dotfiles82026年10月2日 更新

SDiamante13 のスキルをすべて見る

このスキルの問題を報告する