Batch-process your code with popular AI CLI editors.
aitools is a PowerShell module that lets you automate code refactoring, migrations, and documentation tasks using AI coding assistants like Claude Code, Aider, Gemini CLI, and GitHub Copilot CLI.
aitools wraps agentic CLI tools β AI assistants that actually read, understand, and rewrite your code β making them scriptable and repeatable through PowerShell.
In 30 seconds:
# Install the module
Install-Module aitools
# Install Claude Code
Install-AITool -Name ClaudeCode
# Migrate all your Pester tests from v4 to v5
Get-ChildItem tests\*.Tests.ps1 | Update-PesterTestThat's it. aitools coordinates the AI, handles file I/O, tracks changes, and gives you PowerShell's predictability.
The problem with AI coding assistants isn't their capability β it's their interface. Each CLI has different flags, installation steps, and quirks. When you need to process 100 files, you either:
- Click through each one manually in an IDE
- Write brittle shell scripts that break when the CLI changes
- Build your own wrapper (what I did, then shared)
aitools solves this by:
- Providing one consistent interface across multiple AI CLIs
- Making batch operations simple: pipe files in, get results out
- Handling the boring parts (installation, updates, configuration)
- Tracking what changed for review before committing
You might wonder why this exists when PSOpenAI is available. The answer: they solve different problems.
| API Wrappers (like PSOpenAI) | Agentic CLI Tools (like Claude Code) |
|---|---|
| Send prompts, receive text | Open files, understand code, make edits |
| You handle file I/O and context | Built-in file management and context |
| Great for generating new content | Great for refactoring existing code |
| Requires scaffolding for code work | Ships with full coding toolchain |
PSOpenAI is excellent for what it does. aitools is for when you need an AI to edit code, not just generate text.
- PowerShell 3+ or later
- Windows, Linux, or macOS
Install-Module aitools -Scope CurrentUserPick the AI assistant you want to use:
# Install one
Install-AITool -Name ClaudeCode
# Or several
Install-AITool -Name Gemini, Aider
# Or all of them
Install-AITool -Name AllSet-AIToolDefault -Tool ClaudeCodeNow any aitools command will use Claude Code unless you specify otherwise.
Get-ChildItem ./tests/*.Tests.ps1 | Update-PesterTestThis updates your Pester v4 tests to v5 syntax β handling BeforeAll/AfterAll blocks, Context/Describe changes, and parameter validation.
Get-ChildItem ./public/*.ps1 |
Invoke-AITool -Prompt "Add complete comment-based help with 3 examples"Get-ChildItem *.ps1 -Recurse |
Invoke-AITool -Prompt "Apply One True Brace Style formatting"Invoke-AITool -Path ./script.ps1 -Prompt "Optimize this" -Tool AllRun the same task through all installed AI tools and compare results.
| Tool | Best For | Pricing | Status |
|---|---|---|---|
| Claude Code | Complex refactoring, best overall coder | Subscription | β Supported |
| Gemini CLI | Large context windows, generous free tier | Free + paid | β Supported |
| Aider | Reliable diffs, fast iteration | Free + paid | β Supported |
| GitHub Copilot | Integration with GitHub workflow | Free + paid | β Supported |
| Codex CLI | Fast processing | Subscription | β Supported |
| Cursor AI | IDE integration | Free + paid | β Supported |
| Ollama | Offline use, completely free | Free | β Supported |
Each tool has different strengths. Claude Code is the strongest coder but can struggle with files over 400 lines. Gemini has massive context windows. Ollama runs locally with no API costs. Use what fits your needs.
Every aitools operation follows the same pattern:
- Input β Provide files and a prompt
- Processing β AI reads, understands, and edits
- Review β You see diffs and decide to keep or discard
This mirrors manual code review but scales to hundreds of files.
You can provide:
- Inline prompts: Quick instructions right in the command
- Prompt files: Reusable
.mdfiles with detailed instructions - Context files: Reference docs, style guides, API specifications
Example with all three:
$params = @{
Path = "./src/*.ps1"
PromptFilePath = "./prompts/api-migration.md"
ContextFilePath = @(
"./docs/new-api-spec.md",
"./docs/style-guide.md"
)
Tool = "ClaudeCode"
}
Invoke-AITool @paramsThe AI reads the prompt for what to do, the context for how to do it, and processes each file accordingly.
The BurntToast module wraps Windows notification APIs. When Microsoft updated from Windows 10 to Windows 11 APIs, the module needed refactoring.
$params = @{
Path = "./burnttoast/*.ps1"
PromptFilePath = "./prompts/api-upgrade.md"
ContextFilePath = @(
"./docs/windows11-toast-sdk.md",
"./docs/styleguide.md"
)
Tool = "ClaudeCode"
}
Invoke-AITool @paramsThis handles namespace changes, XML property renames, and layout differences β automatically refactoring the entire module.
The dbatools.io blog needed systematic updates: broken links, deprecated commands, outdated screenshots, and stale Twitter embeds. The challenge required judgment, not mechanical find-replace.
The requirements:
- Fix broken links but preserve historical context
- Remove Twitter/X embeds while keeping meaning
- Convert PowerShell screenshots to Hugo shortcodes
- Update deprecated command names
- Consider splatting for readability (but not blindly)
- Maintain author voice and historical accuracy
The solution:
Set-AIToolDefault -Tool ClaudeCode
Get-ChildItem *.md | Invoke-AITool -Prompt ./prompts/audit-blog.mdUsing a 300-line prompt that encoded all the nuance, Claude Code processed hundreds of posts, making judgment calls throughout:
- Tested and replaced dead links
- Converted Twitter embeds to paraphrased statements
- Extracted commands from screenshots and converted to shortcodes
- Applied splatting only where it improved clarity
- Updated deprecated references while preserving historical context
This demonstrates what agentic CLIs do well: read complex requirements, maintain context, and exercise judgment at scale.
$params = @{
Tool = 'Codex'
Prompt = 'Create a Hugo website using colors from this design'
Attachment = '.\design.png'
}
Invoke-AITool @paramsThe -Attachment parameter works with image files (.png, .jpg, .jpeg, .gif, .bmp, .webp, .svg) and is currently only supported by Codex.
# Set default model
Set-AIToolConfig -Tool ClaudeCode -Model claude-sonnet-4-5
# Update all installed tools
Update-AITool# Skip the first 30 files, process the next 20
Get-ChildItem tests\*.Tests.ps1 |
Update-PesterTest -First 20 -Skip 30 -VerboseUseful for debugging prompts or resuming interrupted batches.
The included Jupyter notebook (demo.ipynb) walks through migrating dbatools' 3,500+ Pester tests from v4 to v5. It shows:
- Setup β Import module, configure defaults, prepare workspace
- Execution β Open a real test file and run
Update-PesterTest - Review β Examine structural changes, parameter updates, style enforcement
The demo achieves ~80% automation accuracy, with remaining fixes due to legacy code quality. It illustrates how aitools combines PowerShell's predictability with AI's flexible reasoning.
Pull requests are welcome. Please ensure:
- Code follows PowerShell best practices
- All parameter passing uses splatting
- Functions include complete comment-based help
- Changes are tested on Windows, Linux, and macOS
- New tools follow the existing
$ToolDefinitionspattern
- Issues: GitHub Issues
- Module Gallery: PowerShell Gallery
