The AI-powered, context-aware shell layer for developers.
Documentation | Guide | Contributing
DeftShell sits on top of your existing shell (Zsh, Bash, or Fish) and makes it intelligent — it auto-detects your project stack, connects to 6 AI providers, warns about dangerous commands before they run, learns your patterns, and lets you define reusable workflows.
Think of it as what GitHub Copilot is to your editor, but for your terminal.
AI is optional. Stack detection, the safety engine, smart prompt, runbooks, plugins, analytics, and shell integration all work fully offline — no API key required. AI only powers a small group of commands (ask, do, how, explain, review, chat, generate, runbook generate). See the Commands section for the breakdown.
- Zero config to start. Run
eval "$(ds init zsh)"and it works. Context detection, safety checks, and smart prompt happen automatically. - AI that knows your project. When you run
ds ask, the AI already knows your language, framework, services, and git state — no copy-pasting context. - 6 AI providers, one interface. Anthropic, OpenAI, Gemini, Ollama, GitHub Copilot, and AWS Bedrock. Switch with a flag (
--provider ollama). Set up fallback chains. - Safety net built in. 29 built-in rules warn about
rm -rf /,git push --force main,DROP TABLE, and more — before they execute. Context-aware risk elevation on production branches. - Privacy mode. One command (
ds privacy on) routes all AI through local Ollama. Nothing leaves your machine. - Pure Rust. Single static binary, fast startup, no runtime dependencies.
| Feature | What it does |
|---|---|
| Context Detection | Auto-detects language, framework, package manager, services, CI/CD, and cloud provider from project files |
| AI Gateway | Multi-provider AI with automatic fallback (Anthropic, OpenAI, Gemini, Ollama, GitHub Copilot, AWS Bedrock) |
| Safety Engine | Warns about dangerous commands with configurable risk levels and context-aware elevation |
| Command Intelligence | Typo correction, alias suggestions, command sequence detection, and analytics |
| Runbooks | Define, record, and replay multi-step workflows (deploy scripts, setup procedures) with variables |
| Plugin System | Extend DeftShell with JavaScript plugins distributed via npm |
| Smart Prompt | Git branch/status, detected framework, environment, execution time — all in your prompt |
| Privacy Mode | Route all AI queries through local models (Ollama) when enabled |
Pick one method, then follow the shell setup below.
curl -fsSL https://raw.githubusercontent.com/utsabpanta/deftshell/main/scripts/install.sh | shThis downloads a prebuilt binary for your platform and installs it to /usr/local/bin. Requires a tagged release.
cargo install --git https://github.com/utsabpanta/deftshell.git ds-cliThis builds from source and installs the ds binary to ~/.cargo/bin/. Requires Rust 1.75+.
git clone https://github.com/utsabpanta/deftshell.git
cd deftshell
cargo build --releaseThe binary is at target/release/ds. Add it to your PATH:
# Add to ~/.zshrc or ~/.bashrc
export PATH="/path/to/deftshell/target/release:$PATH"Add one of these lines to your shell config, then restart your shell:
Zsh (~/.zshrc):
eval "$(ds init zsh)"Bash (~/.bashrc):
eval "$(ds init bash)"Fish (~/.config/fish/config.fish):
ds init fish | sourceThis registers shell hooks for safety warnings, command tracking, context detection on cd, and the smart prompt.
ds version # Should print v0.1.0
ds doctor # Checks that everything is wired upThe fastest path if you already have GitHub CLI:
gh auth login # If not already logged in
ds auth copilot # Auto-detects token, sets as defaultOr use any other provider:
ds auth anthropic # Prompts for API key, stores securely
ds auth openai
ds auth gemini
ds auth bedrock # AWS profile setupFor fully local/private AI:
ollama serve && ollama pull llama3.1
ds config set ai.default_provider ollama# AI with project context
ds ask "how do I set up the database for this project?"
ds do "find all TODO comments in src/"
ds how "deploy this to production"
# Pipe output to AI
cat error.log | ds explain
git diff --staged | ds review
# Interactive chat (can execute code blocks from AI responses)
ds chat
# See what DeftShell detected about your project
ds context
ds scripts
ds envCommands marked [AI] require a configured AI provider (see AI Provider Setup). Everything else works offline with zero credentials.
| Command | Description |
|---|---|
ds ask <query> |
[AI] Ask a question with automatic project context |
ds do <instruction> |
[AI] AI generates a shell command, you confirm, it runs |
ds how <question> |
[AI] Get project-aware how-to instructions |
ds explain |
[AI] Pipe command output to AI for explanation |
ds review |
[AI] Pipe diffs to AI for code review |
ds chat |
[AI] Interactive AI chat with conversation history |
ds generate <type> [name] |
[AI] Generate boilerplate (component, migration, test, dockerfile, github-action) |
| Command | Description |
|---|---|
ds context |
Show detected project stack |
ds context refresh |
Force re-detection |
ds context export |
Export context as JSON |
ds scripts |
List runnable scripts (package.json, Makefile, etc.) |
ds run <script> |
Run a detected project script |
ds workspace list |
List monorepo packages |
ds env |
Show environment info (runtimes, git, AI status) |
All runbook commands work offline except ds runbook generate.
| Command | Description |
|---|---|
ds runbook new <name> |
Create a new runbook |
ds runbook run <name> |
Execute a runbook (with variables and step confirmation) |
ds runbook record |
Start recording your commands as a runbook |
ds runbook stop |
Stop recording and save |
ds runbook list |
List all runbooks |
ds runbook generate <desc> |
[AI] Generate a runbook from a description |
| Command | Description |
|---|---|
ds config |
Open config in $EDITOR, or use get/set subcommands |
ds auth <provider> |
Authenticate an AI provider |
ds auth status |
Show auth status for all providers |
ds stats [today|week] |
Command analytics dashboard |
ds usage |
AI token usage by provider and period |
ds plugin list |
Manage plugins (install, remove, enable, disable) |
ds alias add name=cmd |
Manage shell aliases |
ds doctor |
Diagnose setup issues |
ds privacy <on|off> |
Toggle privacy mode (local AI only) |
DeftShell supports 6 providers. Use ds auth <provider> for guided setup, or set env vars directly:
| Provider | Auth | Default Model |
|---|---|---|
| GitHub Copilot | gh auth login (auto-detected) |
gpt-4o |
| Anthropic | ANTHROPIC_API_KEY or ds auth anthropic |
claude-sonnet-4-20250514 |
| OpenAI | OPENAI_API_KEY or ds auth openai |
gpt-4o |
| Gemini | GEMINI_API_KEY or ds auth gemini |
gemini-pro |
| Ollama | None (localhost) | llama3.1 |
| AWS Bedrock | AWS credentials + ds auth bedrock |
anthropic.claude-3-sonnet |
Override for a single command: ds ask "hello" --provider ollama
Set up automatic fallback:
# ~/.deftshell/config.toml
[ai]
default_provider = "anthropic"
fallback_provider = "ollama"DeftShell warns about dangerous commands before execution via shell hooks:
$ rm -rf /
⚠ CRITICAL: Destructive Command Detected
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Command: rm -rf /
Risk: CRITICAL
Reason: Recursive force deletion of root directory
Suggestion: Specify the exact directory you want to remove
29 built-in rules across 4 risk levels (Critical, High, Medium, Low). Risk is automatically elevated on protected branches (main, production) and in production Kubernetes contexts.
Add custom rules in .deftshell.toml:
[[safety.custom_rules.rule]]
pattern = "prisma migrate reset"
level = "high"
message = "This will reset the entire database."Hierarchical TOML config — each layer overrides the previous:
- Built-in defaults
~/.deftshell/config.toml(global).deftshell.toml(project-level, commit to repo)- Environment variables (
DS_*) - CLI flags (
--provider,--yes, etc.)
# ~/.deftshell/config.toml
[ai]
default_provider = "copilot"
fallback_provider = "ollama"
[prompt]
theme = "default" # default, minimal, powerline, pure
show_git = true
show_execution_time = true
[safety]
enabled = true
confirm_threshold = "medium"┌──────────────────────────────────────────────────────┐
│ DeftShell (ds) │
├──────────────────────────────────────────────────────┤
│ Shell Integration │ Context Engine │ AI Gateway │
│ Command Intel │ Plugin System │ Safety Engine │
│ Runbook Manager │ Smart Prompt │ Config Manager │
├──────────────────────────────────────────────────────┤
│ SQLite Storage + Keychain │
└──────────────────────────────────────────────────────┘
Built as a Rust workspace:
ds-core— Core library (AI gateway, context detection, safety engine, runbooks, shell integration, storage)ds-cli— CLI binary (clap-based, 30+ subcommands)ds-plugin-sdk— Rust plugin SDK
See CONTRIBUTING.md for development setup. Quick start:
cargo build --workspace # Build
cargo test --workspace # Test (193 tests)
cargo clippy --workspace -- -D warnings # LintMIT — see LICENSE for details.