Логотип Powershell Refactor

Powershell Refactor

Сообщество
mickpletcher
powershell-refactor

Refactor existing PowerShell scripts to simplify flow, reduce duplication, standardize naming and structure, and tighten behavior without changing the intended outcome.

Обзор

Издательmickpletcher
РепозиторийAI-Skills
Название навыкаpowershell-refactor
Звёзды
21
Форки
3
Встроенные файлы
3
ЛицензияMIT
Ссылки
  • Инструкции в формате Markdown

    Файл SKILL.md, который модель загружает по необходимости, поэтому токены расходуются только при подходящем запросе.

  • Работает с любой языковой моделью

    Навыки ИИ — это обычный Markdown, а не код для конкретного поставщика, поэтому они работают с GPT, Claude, Gemini, Grok и локальными моделями.

  • Файлы в комплекте: 3

    Скрипты, шаблоны и справочные материалы, которые модель может читать во время работы. Файлы доступны только для чтения и никогда не выполняются.

  • Открытый исходный код

    Опубликовано на GitHub: mickpletcher. Перед установкой изучите исходные материалы.

Установка

Установите навык ИИ Powershell Refactor в TypingMind, чтобы использовать его с любой LLM, или добавьте его в другой агент, который умеет читать SKILL.md.

1

Установка в TypingMind

TypingMind устанавливает навык прямо из его папки на GitHub: читает SKILL.md, собирает файлы ресурсов и сохраняет результат локально.

  1. Откройте приложение и перейдите в раздел «Плагины → Навыки».
  2. Выберите «Установить из GitHub».
  3. Вставьте указанную ниже ссылку на папку навыка и подтвердите установку.
    https://github.com/mickpletcher/AI-Skills/tree/main/claude/skills/powershell-refactor
  4. Включите навык в каждом чате, где хотите его использовать.
Плагины → Навыки → Новый навык → По ссылке GitHub, затем вставьте ссылку на папку и нажмите «Продолжить».
2

Установка в другом агенте

Любой агент с поддержкой формата Agent Skills может использовать этот навык — скопируйте папку в каталог навыков этого агента.

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/claude/skills/powershell-refactor .claude/skills/powershell-refactor
После копирования перезапустите Claude Code, чтобы загрузить новый навык.

Использование в TypingMind

Включите навык Powershell Refactor в любом чате TypingMind, и дальше модель всё сделает сама. Его название и описание хранятся в системном промпте, а при появлении подходящего запроса модель сама загружает полные инструкции. Вам не нужно вызывать навык вручную, и до фактического использования он не расходует токены.

Модель сама загружает навык Powershell Refactor, как только появляется подходящий для него запрос.

Работает с любой моделью ИИ

Навыки ИИ — это обычные инструкции в Markdown, а не код для конкретного поставщика, поэтому навык Powershell Refactor не привязан к модели, для которой он был создан. Установите его один раз в TypingMind и используйте с GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama или локальной моделью, которую запускаете самостоятельно, — со своими API-ключами.

  • Загружается только при необходимости

    Системный промпт содержит только название и описание. Инструкции загружаются при первом подходящем запросе, поэтому неиспользуемый навык не расходует токены.

  • Меняйте модели прямо в чате

    Навык состоит из инструкций, а не кода, поэтому смена модели не нарушает его работу: новая модель читает тот же файл SKILL.md.

Инструкции навыка

Это содержимое файла SKILL.md, которое загружает модель. Прочитайте его перед установкой: навык — это инструкции, которым будет следовать ваша модель.

PowerShell Refactor Skill

Intent

Use this skill to improve an existing PowerShell script that already works or mostly works but needs cleanup. The goal is to make the code smaller, clearer, more idiomatic, and easier to maintain without introducing unnecessary abstractions or changing the script's job.

Use When

  • A PowerShell script feels repetitive, bloated, inconsistent, or hard to follow
  • Function names, parameter names, or output patterns need to be standardized
  • The user wants a script simplified, tightened, cleaned up, or refactored
  • The script should be aligned with practical PowerShell conventions for real admin automation

Do Not Use When

  • The main task is to create a brand new script from scratch
  • The request is mostly about documentation, README writing, or tutorial content
  • The user wants a major architecture redesign instead of a focused refactor
  • The script's expected behavior is unclear and changing it would be risky

Workflow

  1. Read the existing script first and identify the real behavior that must stay intact.
  2. Find the highest value cleanup targets:
    • duplicated logic
    • dead code
    • inconsistent naming
    • unclear control flow
    • noisy error handling
    • unnecessary wrappers or abstractions
  3. Refactor in place with the smallest set of edits that materially improves the script.
  4. Prefer native PowerShell patterns:
    • approved verbs
    • clear parameter blocks
    • pipeline-aware logic when it adds value
    • try and catch only where they improve control and diagnostics
    • Write-Verbose, Write-Warning, and structured output instead of ad hoc console noise
  5. Keep function boundaries practical. Split code only when it improves readability or reuse in a clear way.
  6. Recheck for behavior drift, naming consistency, and obvious lint or test issues before finishing.

Scope Presets

Let the user control how aggressive the pass is. Default to full cleanup when no preset is named:

  • naming only: rename functions to approved verbs, standardize parameter and variable casing, touch nothing else
  • deduplication only: collapse repeated logic into shared functions or loops, keep all names and structure otherwise
  • full cleanup: the complete workflow above

When the user names a preset, stay inside it even when other cleanup targets are visible; list the out-of-scope findings at the end instead of fixing them.

PSScriptAnalyzer Alignment

Run Invoke-ScriptAnalyzer on the script before and after when it is available, honoring any PSScriptAnalyzerSettings.psd1 in the repo. Fix the violations that fall inside the chosen scope preset, and list any remaining ones with a one-line reason they were left, such as a deliberate Write-Host for interactive output. The refactor should never introduce new violations.

Change Summary

End every refactor with a before-and-after summary so the user can review the pass at a glance:

text
Refactor Summary
- Behavior preserved: [yes / exceptions explicitly listed]
- Lines: [before] -> [after]
- Changes:
  - [each behavior-preserving change in one line, e.g. "merged 3 duplicate retry blocks into Invoke-WithRetry"]
- Analyzer: [violations fixed] fixed, [count] remaining (listed above)
- Out of scope findings: [anything noticed but not touched]

Constraints

  • Preserve the script's intended behavior unless the user explicitly asks for a behavior change
  • Prefer editing existing files over creating new ones
  • Remove obsolete code instead of keeping compatibility shims
  • Do not add layers, helper classes, or extra modules unless the current script clearly needs them
  • Keep output, parameters, and side effects predictable
  • Use comments only where the logic would otherwise be hard to follow
  • If a destructive or high risk action is present, preserve or improve safety controls such as ShouldProcess, confirmation, or validation

References

  • shared/skill-standard.md
  • shared/naming-conventions.md
  • Existing repo patterns in the target script's project

Help And Examples

Use this skill when the user already has a PowerShell script and wants it cleaned up, simplified, or standardized.

Minimum useful input:

  • the .ps1 or .psm1 file to refactor
  • the behavior that must stay the same
  • any style constraints such as approved verbs, no comments, or keeping it single file

Example prompts:

text
Refactor this PowerShell script to reduce duplication and make the error handling cleaner, but keep the same output and parameters.
text
Tighten this Intune reporting script. Keep it as one file. Rename functions to approved verbs and remove unnecessary abstraction.
text
Clean up this PowerShell module and standardize the parameter blocks without changing how the commands behave.

Validation Checklist

  • The refactor preserves the intended behavior of the original script
  • Naming, structure, and flow are more consistent than before
  • Unnecessary duplication or dead code has been removed
  • The result uses practical PowerShell conventions instead of generic abstractions
  • Any tests, lint checks, or quick validation steps relevant to the target repo still pass

Встроенные файлы

Модель читает эти файлы по мере необходимости, пока навык загружен. Они доступны только для чтения и никогда не выполняются.

Часто задаваемые вопросы

Что делает навык ИИ Powershell Refactor?

Refactor existing PowerShell scripts to simplify flow, reduce duplication, standardize naming and structure, and tighten behavior without changing the intended outcome.

Зачем использовать Powershell Refactor в TypingMind?

Потому что вы устанавливаете навык один раз и используете его с любой моделью. Powershell Refactor — это обычный текст в формате Markdown, а не код для конкретного поставщика, поэтому один и тот же навык работает с GPT-5, Claude, Gemini, Grok или локальной моделью. Вы можете менять модель прямо во время чата, и навык продолжит работать. TypingMind использует ваши собственные ключи API, поэтому вы платите поставщикам напрямую, а не оформляете подписку с оплатой за каждое место. Ваши навыки и чаты остаются в вашем собственном хранилище.

Как установить Powershell Refactor в TypingMind?

В TypingMind откройте «Плагины → Навыки → Установить из GitHub» и вставьте https://github.com/mickpletcher/AI-Skills/tree/main/claude/skills/powershell-refactor. TypingMind прочитает файл SKILL.md, включит сопутствующие файлы в пакет и установит навык, который можно включать отдельно для каждого чата.

Какие модели ИИ могут использовать Powershell Refactor?

Любая модель, которую вы подключите в TypingMind. Навыки ИИ — это обычные инструкции в формате Markdown, а не код для конкретного поставщика, поэтому GPT, Claude, Gemini, Grok и локальные модели могут загружать этот навык, когда запрос ему соответствует.

Со сколькими моделями ИИ можно использовать Powershell Refactor?

С любым количеством. Если модель поддерживает навыки, вы можете использовать с ней Powershell Refactor: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama и другие — всё в TypingMind с вашими собственными ключами API.

Бесплатен ли навык ИИ Powershell Refactor?

Да. Навык опубликован на GitHub автором mickpletcher по лицензии MIT. Вы платите только своему поставщику ИИ за использованные токены.

Что такое навыки ИИ?

Навык ИИ — это многоразовый набор инструкций, который объясняет модели ИИ, как выполнять конкретную задачу. Он соответствует открытому формату Agent Skills: файл SKILL.md с названием и описанием, а также любые скрипты, шаблоны или справочные файлы, которые могут понадобиться модели. Модель читает инструкции, только когда ваш запрос соответствует навыку, поэтому установленный навык ничего не стоит, пока не используется.

Чем навыки ИИ отличаются от плагинов и серверов MCP?

Плагин или сервер MCP даёт модели новые инструменты для вызова — код, который где-то выполняется и возвращает результат. Навык ИИ вместо этого даёт модели знания и порядок действий: как подойти к задаче, какие шаги выполнить и каким должен быть хороший результат. Навыки — это обычный текст в формате Markdown, поэтому им не нужны сервер, ключ API или среда выполнения, и они работают с любой моделью.

Все

Создайте свою рабочую ИИ-среду сейчас

Подпишитесь на нашу рассылку, чтобы узнавать о новых функциях и предстоящих розыгрышах 👇