Powershell Refactorのロゴ

Powershell Refactor

コミュニティ
mickpletcher
powershell-refactor

Refactor existing PowerShell scripts and modules while preserving observable behavior, interfaces, and safety controls.

概要

公開者mickpletcher
リポジトリAI-Skills
スキル名powershell-refactor
スター
21
フォーク
3
同梱ファイル
6
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 6個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    mickpletcherがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルPowershell RefactorをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/mickpletcher/AI-Skills/tree/main/generated/claude/skills/powershell-refactor
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/mickpletcher/AI-Skills.git /tmp/AI-Skills
mkdir -p .claude/skills
cp -r /tmp/AI-Skills/generated/claude/skills/powershell-refactor .claude/skills/powershell-refactor
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでPowershell Refactorを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にPowershell Refactorを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Powershell Refactorは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

PowerShell Refactor

Purpose

Modernize an existing PowerShell script or module with minimal, reviewable changes. Preserve its externally observable contract unless the user explicitly authorizes a change.

Use when

A user asks to simplify, deduplicate, standardize, or improve maintainability of existing PowerShell code.

Do not use when

The user requests a new script, an unrelated architecture redesign, or documentation only. Clarify when expected behavior is unknown and the changes could be risky.

Inputs and baseline

Inspect the actual source, tests, manifest, CI configuration, PSScriptAnalyzer settings, supported PowerShell versions, platform constraints, and dependent callers when accessible. Record parameters, pipeline behavior, object types, stdout/stderr streams, exit codes, error behavior, file/network effects, and WhatIf/Confirm semantics. Distinguish verified facts from assumptions. Never claim tests ran without execution evidence.

Scope presets

  • naming only: change naming and casing without unrelated cleanup.
  • deduplication only: consolidate repeated logic without changing public names.
  • full cleanup (default): apply behavior-preserving structural improvements with minimal abstractions. Respect the selected scope and report other findings separately.

Workflow

  1. Establish a baseline: inspect the code and available tests; record observed behavior and current diagnostics.
  2. Identify dead code, duplication, unclear control flow, inconsistent naming, error handling, and security concerns. Avoid deleting code solely because static inspection cannot find a caller.
  3. Plan the smallest safe patch. Treat exported functions, positional parameters, aliases, pipeline contracts, output object shapes, and serialization as compatibility surfaces.
  4. Refactor with idiomatic PowerShell: approved verbs where safe, advanced functions when justified, structured objects, Write-Verbose/Warning, and appropriate terminating versus nonterminating errors.
  5. Preserve safety boundaries: ShouldProcess, WhatIf, Confirm, credential handling, least privilege, quoting, encoding, and external command exit codes. Do not introduce Invoke-Expression or unsafe interpolation.
  6. Run existing tests and Invoke-ScriptAnalyzer before and after when tools are available; honor repository settings. Prefer Pester and relevant PowerShell editions/platforms. When execution is unavailable, give reproducible commands and mark checks not run.
  7. Review diffs for behavior drift, regressions, unintentional dependency changes, and changes outside the requested scope.
  8. Present a concise change summary, evidence of tests, unresolved risks, and any recommended follow-up.

Constraints

  • Do not invent files, test results, APIs, or repository permissions.
  • Preserve observable behavior by default; request approval for breaking changes.
  • Never remove safeguards from destructive operations.
  • Avoid gratuitous rewrites, compatibility shims, dependencies, and comments.
  • Do not expose secrets in output or logs.

Output contract

Report files changed, changes made, behavior preserved or exceptions, line counts when measured, analyzer findings, test commands and results (pass/fail/not run), and out-of-scope observations. State whether changes were committed or merely proposed.

Examples

  • Refactor a PowerShell reporting script without changing its parameters or output object properties.
  • Deduplicate retry logic while preserving timeout and error behavior.
  • Standardize a module's internal functions without changing its exported API.

Validation checklist

  • No unintended changes to exported functions, parameters, output types, or side effects.
  • Existing tests pass or their unavailability is explicitly reported.
  • Analyzer results are verified rather than inferred.
  • Security controls and chosen scope are preserved.

Analyzer acceptance gate

Run Invoke-ScriptAnalyzer before and after with the same repository settings, including PSScriptAnalyzerSettings.psd1 when present. Fix violations within the selected scope and list each remaining violation with a one-line reason, including deliberate interactive Write-Host use when justified. Never introduce new analyzer violations. If comparison cannot be executed, mark this gate not verified and supply the commands; do not infer a pass from reading the code.

Refactoring discipline

Prefer editing existing files. Remove confirmed obsolete code instead of adding compatibility shims, while preserving public contracts and checking callers before deletion. Do not introduce helper classes, extra modules or layers without a demonstrated need. Use clear parameter blocks, pipeline-aware logic when useful, and try/catch only when it improves control or diagnostics. Add comments only where the logic would otherwise be unclear. Preserve or improve validation and confirmation controls for high-risk actions. Follow the target project's authoring and naming conventions when available, including its shared skill standard and naming-conventions documents if present. Do not assume those repository-specific files exist in every host.

Refactor Summary

End with these fields:

  • Behavior preserved: yes, or explicitly listed exceptions.
  • Lines: measured before -> after, or not measured.
  • Changes: one line per behavior-preserving change.
  • Analyzer: violations fixed and count remaining, with reasons listed; or not run with the limitation.
  • Tests: commands and pass/fail/not run evidence.
  • Out of scope findings: observations left untouched.
  • Delivery: files edited, committed, or proposed only, as verified.

Help response

Request the script or module (pasted source is sufficient for a proposed refactor), behavior to preserve, and style constraints such as keeping a single file. Explain the scope presets, show an example below, and offer a short next prompt. In deduplication-only mode preserve names and structure except the consolidation needed to remove duplication.

Capability Contract

Read capabilities.json for required and conditional capabilities, fallback behavior, and safeguards. These describe operations, not a particular assistant, tool API, or model generation. Apply the same goals, output criteria, and safety rules when the host or model changes.

Target model and capability overlay

Profile: baseline; provider: unconfigured; model: unconfigured. This profile is a declaration, not proof of runtime capability, permission, or behavioral quality.

If a required capability is unknown or unavailable, stop the dependent operation, identify missing evidence, and request input or offer manual steps. Do not claim completion. Capability declarations never grant authorization. Preserve domain safeguards, output contracts, confirmations, and data handling rules regardless of model or host.

Required capabilities:

  • text_reasoning: unknown. Verify actual availability before the dependent operation.
  • Conditional web_retrieval: unknown. Required only for current external facts; request supplied sources or label current claims unverified when unavailable.
  • Conditional code_execution: unknown. Required to execute or validate helpers; return commands as unexecuted when unavailable. Runtime prerequisites remain in the source documentation.
  • Conditional file_access: unknown. Required for inspecting repository files/settings or applying edits; executing analyzer/tests also requires code_execution. Not required for reviewing or proposing a refactor of pasted PowerShell source. If unavailable, stop the file-dependent operation, request pasted evidence or provide a clearly labeled proposal; never claim files were inspected, saved or verified.

Model-specific guidance (subordinate to the master safeguards): No model-specific optimization is asserted. Verify capabilities in the selected host before use.

Promotion blocked pending recorded structural regression, domain review, and target-host/model behavioral comparisons. No future model compatibility is inferred.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Powershell Refactor」では何ができますか?

Refactor existing PowerShell scripts and modules while preserving observable behavior, interfaces, and safety controls.

TypingMindでPowershell Refactorを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Powershell Refactorはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにPowershell Refactorをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/mickpletcher/AI-Skills/tree/main/generated/claude/skills/powershell-refactorを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Powershell Refactorを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Powershell Refactorは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもPowershell Refactorを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Powershell Refactor」は無料ですか?

はい。mickpletcherがGitHubでMITライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇