Логотип 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, який модель завантажує за потреби, тож токени витрачаються лише тоді, коли запит справді відповідає навичці.

  • Працює з будь-якою LLM

    Навички ШІ — це звичайний Markdown, а не код для певного постачальника, тому вони працюють із GPT, Claude, Gemini, Grok або локальною моделлю.

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

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

  • Відкритий вихідний код

    Опубліковано на GitHub користувачем mickpletcher. Перегляньте вихідний вміст перед установленням.

Встановлення

Установіть навичку ШІ Powershell Refactor у TypingMind, щоб використовувати її з будь-якою LLM, або додайте її до іншого агента, що читає SKILL.md.

1

Встановити в TypingMind

TypingMind встановлює навичку безпосередньо з її папки GitHub — читає SKILL.md, збирає файли ресурсів у пакет і зберігає результат локально.

  1. Відкрийте застосунок і перейдіть до Плагіни → Навички.
  2. Виберіть «Встановити з GitHub».
  3. Вставте наведений нижче URL папки навички та підтвердьте встановлення.
    https://github.com/mickpletcher/AI-Skills/tree/main/claude/skills/powershell-refactor
  4. Увімкніть навичку в кожному чаті, де хочете її використовувати.
Плагіни → Навички → Нова навичка → За URL GitHub, потім вставте URL папки й натисніть «Продовжити».
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, ні середовище виконання, і вони працюють із будь-якою моделлю.

Усі

Створіть власний ШІ-простір уже зараз

Підпишіться на нашу розсилку, щоб дізнаватися про нові функції та майбутні розіграші 👇