Skip to main content

powershell-agent

A natural language interface for PowerShell, powered by Groq. You describe what you want done, and the agent figures out which commands to run, executes them step by step, and gives you a summary of what happened.

Requirements

  • Python 3.10+
  • Windows (PowerShell)
  • Groq API key (free tier works)

Setup

poetry install

$env:GROQ_API_KEY = "gsk_..."

Optional overrides:

Variable Default Description
MODEL_PS llama-3.3-70b-versatile Groq model to use
GITHUB_MCP_URL — Your MCP server URL for --github queries
GITHUB_TOKEN — GitHub PAT for --github queries
PS_MAX_ITERATIONS 10 Max agent loop iterations
PS_TIMEOUT 300 Command timeout in seconds
PS_HISTORY_DIR ~/.powershell-agent/history Where sessions are saved

Usage

# Direct prompt
poetry run powershell-agent "find all TODO comments in python files"

# Review each command before it runs
poetry run powershell-agent --review "create a feature branch for dark mode"

# Interactive
poetry run powershell-agent

CLI Flags

Flag Description
--review Approve / skip / edit / quit each command before it runs
--model <name> Override the model for this session
--iterations <n> Max number of agent iterations
--history List past sessions
--clear-history Delete all saved sessions
--replay <id> Print the commands from a past session
--github "<query>" Query GitHub via MCP (see below)
--version Print version

GitHub MCP

The agent can query GitHub repositories using the Model Context Protocol via Groq's Responses API.

GITHUB_MCP_URL=https://your-mcp-server.com/mcp    # any MCP server URL you want
GITHUB_TOKEN=ghp_...                               # your GitHub PAT (optional, for private repos)

Supported models for --github (Groq Responses API restriction): llama-3.3-70b-versatile, llama-3.1-8b-instant, qwen/qwen3-32b, openai/gpt-oss-120b, openai/gpt-oss-20b

Models like mixtral and gemma are not supported and will return an error. The default model works fine.

$env:GITHUB_TOKEN = "ghp_..."

poetry run powershell-agent --github "summarise the open issues in abderrahmanyouabd/powershell-agent"
poetry run powershell-agent --github "what changed in the last 5 commits of abderrahmanyouabd/powershell-agent"

Session History

Every run is saved to disk automatically.

# List sessions
poetry run powershell-agent --history

# Replay one
poetry run powershell-agent --replay abc123def456

Developer Usage

import asyncio
from powershell_agent import PowerShellAgent, list_sessions

async def main():
    agent = PowerShellAgent()
    response = await agent.run("find all python files and count them")
    print(response)

    # Past sessions
    for s in list_sessions(limit=5):
        print(s["id"], s["prompt_preview"])

asyncio.run(main())

Adding a custom tool

from powershell_agent.tools import build_default_registry

registry = build_default_registry()

schema = {
    "type": "function",
    "function": {
        "name": "my_tool",
        "description": "Does something useful.",
        "parameters": {
            "type": "object",
            "properties": {"input": {"type": "string"}},
            "required": ["input"],
        },
    },
}

async def my_handler(input: str, **_):
    return {"status": "success", "output": f"got: {input}", "error": None, "return_code": 0}

registry.register(schema, my_handler)
agent = PowerShellAgent(registry=registry)

Running Tests

poetry run pytest tests/ -v

Architecture

powershell_agent/
  config.py     # all constants + env-var overrides
  executor.py   # PowerShell subprocess engine
  tools.py      # ToolRegistry + built-in tools (run_powershell, write_file)
  prompt.py     # system prompt builder
  memory.py     # session persistence
  agent.py      # agentic loop
  mcp.py        # GitHub MCP via Groq Responses API
cli.py          # CLI entry point
tests/          # pytest suite

Security

This tool executes PowerShell commands on your machine. Use --review mode when you want to approve each command before it runs, especially for unfamiliar prompts.

License

MIT

Metadata

Release files for powershell-agent 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for powershell-agent 0.3.1
File Size Uploaded Provenance
powershell_agent-0.3.1.tar.gz 13.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for powershell-agent 0.3.1
File Interpreter ABI Platform
powershell_agent-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 31.4 kB

Release files / powershell_agent-0.3.1.tar.gz

Download URL powershell_agent-0.3.1.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f48ed4851ec65c721a25eef526c2ecd9022a9b7f73d00336bd15a9a2a742f02e
BLAKE2b-256 checksum
How to use checksums
a4ab5b2eb4feb3d24bf852dff7a87206f780da495a41e626e6e118c3b9a17f94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.10.0 Windows/10

Release files / powershell_agent-0.3.1-py3-none-any.whl

Download URL powershell_agent-0.3.1-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d00f72b8b1125c159776aeb645b813455e3ae2bda96525f978470741e1c94160
BLAKE2b-256 checksum
How to use checksums
d9206ac1da2e51784f3bac9127fdfa4e60ae6d16f9879f2bc69564388bf261b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.10.0 Windows/10

Security for powershell-agent 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page