本文へ移動
cccskills
無料GitHub で公開日本語紹介

code-structure

複数の機能で重複する処理を整理し、業務ルールを担うアクションと再利用できる処理を担うサービスの分け方や移行手順を示します。

原文原文の説明を見る

Use when multiple workflows duplicate the same operational logic, when deciding what belongs in actions vs shared services, or when refactoring repeated operational blocks across domain flows. Use when adding new features that share mechanics with existing ones.

michaelshimeles/rstackスター 1,392(GitHub 1,392 + cccskills 0)

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • 重複した処理を共通化すべきか判断したいとき
  • 業務ルールと共通処理の置き場所を整理したいとき
  • 複数の呼び出し元を段階的にリファクタリングしたいとき
  • 新機能で既存処理を再利用したいとき

日本語での紹介

できること

複数のワークフローに重複する処理を見つけ、どこを共通化するか考えるための設計指針を示します。基本は、業務ルールや状態遷移、認証確認などの流れをアクション側に置き、メール送信や外部SDKとのやり取りなど再利用できる操作をサービス側にまとめる構成です。既存のドメインサービスやリポジトリ、トランザクションの境界が適切なら、それを尊重します。サービス関数の入力を明示し、結果や失敗を分かる形で返す設計、呼び出し元を一つずつ置き換える移行手順も案内します。

こんなときに便利

同じ処理を複数の機能にコピーしているときや、新機能が既存の流れと共通の仕組みを使うときに役立ちます。共通化による具体的な利点を確認し、不要な抽象化を避けたい場合にも向いています。

使い方の例

  • 「複数のアクションにある重複処理を、どこまでサービスに分けるべきか整理してください」
  • 「既存の構成に合わせて、この共通処理を段階的に移行する案を作ってください」

注意点

特記事項はありません。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(1)

  • SKILL.md4.9 KB

SKILL.md(原文)

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

Service Layer Architecture

Overview

This collection prefers a two-layer separation: actions orchestrate domain rules, while services implement reusable operations. Use it where the project has no established convention. Preserve existing domain services, repositories, transaction boundaries, and framework patterns when they already fit the task.

This prevents duplicated code, inconsistent behavior, and bugs fixed in one path but not others.

When to Use

  • Multiple callers need the same low-level operation (sandbox creation, email sending, payment processing)
  • You're copy-pasting operational logic between action files
  • A bug fix in one workflow doesn't propagate to others doing the same thing
  • Adding a new feature that shares mechanics with existing flows

Avoid extraction that adds indirection without a concrete benefit. Repetition is a useful signal, but a single caller can justify a boundary for testing, provider isolation, transactions, or complex logic.

Core Pattern

Orchestration Layer (Actions)          Service Layer (Shared Mechanics)
├── owns business rules                ├── owns reusable operations
├── owns state transitions             ├── owns provider/SDK interactions
├── owns auth/ownership checks         ├── owns command execution details
├── owns failure classification        ├── owns health checks / readiness
├── owns retries / user-facing errors  └── returns structured results
└── calls service functions

Rule of thumb:

  • "What this product flow means" → keep in actions
  • "How to do this operation reliably" → move to service layer

Quick Reference

Design PrincipleDoDon't
API shapeComposable capability blocksOne giant "do everything" method
Inputs/outputsExplicit dependencies and meaningful resultsHidden global state or undocumented side effects
MigrationExtract one block, replace one caller, verify, then migrate restRefactor everything at once
Domain logicPut policy and transactions in the project's established ownerScatter the same policy across callers
Extraction triggerRepeated mechanics or a concrete boundary benefitSpeculative abstractions with no current benefit

Designing Service Functions

Design as capability blocks, not monoliths:

// Good: composable, each caller chooses what to use
createManagedSandbox(...)
prepareRepo(...)
detectPackageManager(...)
installDependencies(...)
runBuildCommand(...)
startSandboxRuntime(...)

Each function should:

  • Accept all required data as explicit parameters
  • Return structured outputs (e.g., { ready, previewUrl, proxyPort })
  • Inject database or repository access when the service owns persistence under the project's architecture. State writes and transaction boundaries explicitly.
  • Make failure explicit through typed results or documented exceptions

This lets callers choose strict vs relaxed behavior per flow.

Migration Checklist

When extracting shared logic:

  1. Identify the existing owners of policy, persistence, and transactions
  2. Mark repeated operations or boundaries with a concrete current benefit
  3. Extract a cohesive operation consistent with those owners
  4. Replace one caller → verify → replace remaining callers
  5. Preserve auth, status transitions, error handling, and transaction behavior
  6. Run verification: typecheck, lint, confirm all flows still work

Anti-Patterns

Anti-PatternProblem
God serviceOne huge function hides all control flow
Leaky serviceHidden state changes or unclear transaction ownership
Inconsistent APIEach function uses different argument styles and error semantics
Over-abstractionIndirection with no reuse, testability, or boundary benefit

Example: Email Service (Simple)

// emailService.ts — shared mechanics
export async function sendWelcomeEmail(params: { to: string; name: string }) {
  const html = `<h1>Welcome ${params.name}</h1>`;
  await emailProvider.send(params.to, "Welcome", html);
}

// userSignup.ts — orchestration (owns WHEN to send)
if (user.marketingOptIn) {
  await sendWelcomeEmail({ to: user.email, name: user.name });
}

// adminInvite.ts — orchestration (different business rule, same mechanic)
await sendWelcomeEmail({ to: invitee.email, name: invitee.name });

Mental Model

Existing architecture? → Follow its boundaries
No convention? → Prefer actions for orchestration and services for operations
Extraction? → Name its concrete benefit before adding another layer

Keep responsibilities clear, dependencies explicit, and side effects visible.

レビュー

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

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

before-and-after

無料概要あり

Webページや画像の変更前後を同じ条件で撮影し、画面の差を比べるためのスクリーンショットと、必要に応じて共有用Markdownを作成します。

  • UI変更の前後を比較したいとき
  • PR用の画面比較資料を作りたいとき
  • 特定のページ要素だけ撮影したいとき
michaelshimeles/rstack1,3922026年10月26日 更新

evidence-driven-testing

無料概要あり

アプリの操作や変更後の動作を確かめ、画面録画やスクリーンショット、測定結果などの証拠をまとめて、指定先に結果を届けます。

  • UI操作を録画して動作を示したいとき
  • GUIなしで画面の状態を検証したいとき
  • APIや性能の変更を数値で確かめたいとき
michaelshimeles/rstack1,3922026年10月26日 更新

greploop

無料概要あり

PRやMRに寄せられたGreptileの指摘を確認し、対象を絞った修正と再レビューを繰り返して、現行リビジョンの評価と未対応事項を整理します。

  • PRのGreptile指摘を修正したいとき
  • MRのレビューを再依頼して確認したいとき
  • Perforceの変更をレビューしたいとき
michaelshimeles/rstack1,3922026年10月26日 更新

greploop-apps

無料概要あり

通常のトリガーで大きなPRを処理できない場合に、`greploop` のワークフローを `@greptile-apps` トリガーで実行する互換用エントリーポイントです。

  • 大きなPRをGreptile Appsで処理したいとき
  • 通常のトリガーで扱えないPRをレビューしたいとき
  • 既存のgreploopワークフローを指定トリガーで実行
michaelshimeles/rstack1,3922026年10月26日 更新

new-feature

無料概要あり

機能追加や修正に着手する前に、作業ごとのGit worktreeとブランチを用意し、既存の担当作業や変更範囲を確認して安全に編集を進めます。

  • 機能追加を専用ブランチで始めたいとき
  • 共有チェックアウトを保って修正したいとき
  • 既存PRとの変更範囲を確認したいとき
michaelshimeles/rstack1,3922026年10月26日 更新

unslop

無料概要あり

コミット文やPR、ドキュメント、返信など、人が読む文章からAIらしい定型表現を取り除き、意味と口調を保ちながら具体的で自然な文に整えます。

  • PR本文を自然な文に整えたいとき
  • コミットメッセージを推敲したいとき
  • ドキュメントの定型表現を減らしたいとき
michaelshimeles/rstack1,3922026年10月26日 更新

michaelshimeles のスキルをすべて見る

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