Skip to main content
skill CX Codex

shell-integration — Claude Code skill: what it does, how to install

The shell-integration Claude Code skill provides terminal integration guides and Bash, Zsh, and Fish patterns for completions, prompt hooks, and portable POSIX wrappers.

MIT 123 installs ★ 29 updated 2026-08-17

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add oakoss/agent-skills --skill shell-integration -a claude-code
Open on GitHub

What shell-integration does

This skill supplies patterns for building software that ties directly into Unix command shells. It details completion registration (compdef, compgen, fish complete), ZLE widgets, key mapping via bindkey, and lifecycle hooks including precmd, preexec, and PROMPT_COMMAND. It also outlines terminal styling using ANSI escape sequences, tput, stty, and process management via signals.

The material focuses on avoiding standard portability pitfalls. It enforces appending to PROMPT_COMMAND with +=, swapping fragile echo -e calls for printf, wrapping arguments strictly as "$@", and testing POSIX scripts against dash rather than assuming Bash defaults.

Because user-invocable is set to false, you do not trigger this skill via slash commands. The coding agent pulls its instructions automatically whenever working on CLI tools, dotfiles, or shell plugins.

What it helps with

  • build cross-shell autocompletion scripts for Zsh, Bash, and Fish
  • register non-destructive prompt hooks using add-zsh-hook or PROMPT_COMMAND
  • manage terminal cleanup reliably using EXIT and INT traps
  • write portable POSIX installation scripts compatible with dash

Example prompts for the agent

  • Generate shell completion files for my CLI tool covering Zsh, Bash, and Fish subcommands
  • Build a Zsh prompt hook using add-zsh-hook that isolates options with emulate -L zsh
  • Audit this shell installer script for POSIX sh compliance and missing argument quotes

How to install shell-integration

1Skills CLI (Vercel)

npx skills add oakoss/agent-skills --skill shell-integration -a claude-code

2Manually: put the files in place

~/.claude/skills/shell-integration/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/shell-integration/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about shell-integration

How to install shell-integration in Claude Code?

Run npx skills add oakoss/agent-skills --skill shell-integration -a claude-code in your terminal. The skill file is placed at ~/.claude/skills/shell-integration/SKILL.md.

What does shell-integration do?

It provides your AI agent with reference patterns for terminal control, shell completions, signal traps, and script distribution across Bash, Zsh, and Fish.

Can I invoke shell-integration manually?

No, it sets user-invocable: false. Your assistant reads it in the background whenever a task requires shell scripting or terminal integration.

Source text

SKILL.md · MIT
---
name: shell-integration
description: |
  Shell scripting and terminal integration patterns for building tools that integrate with Zsh, Bash, and Fish. Covers completion systems (compdef/compadd, complete/compgen, fish complete), ZLE widgets, hooks (precmd/preexec/chpwd, PROMPT_COMMAND), readline, bindkey, parameter expansion, ZDOTDIR loading order, event systems, abbreviations, POSIX shell scripting, terminal control codes (ANSI/CSI escape sequences), tput, stty, signal handling, process management (job control, traps), and shell plugin distribution patterns.

  Use when building shell plugins, writing completion scripts, implementing terminal UI with escape sequences, managing dotfiles, creating installation scripts, handling signals and process management, or integrating native binaries with shell wrappers.
license: MIT
metadata:
  author: oakoss
  version: '1.0'
user-invocable: false
---

# Shell Integration

## Overview

Shell integration covers the APIs and patterns for building tools that extend or interact with Unix shells. This includes completion systems, prompt hooks, key bindings, terminal control, and plugin distribution across Zsh, Bash, and Fish.

**When to use:** Building CLI tool completions, shell plugins, prompt customizations, terminal UI, dotfile managers, installation scripts, or native binary wrappers.

**When NOT to use:** General-purpose scripting unrelated to shell extension (use POSIX scripting reference for standalone scripts), GUI applications, or web server development.

## Quick Reference

| Pattern             | Shell | Key Points                                                      |
| ------------------- | ----- | --------------------------------------------------------------- |
| Completion function | Zsh   | `compdef`, `compadd`, `zstyle` for matcher configuration        |
| Completion function | Bash  | `complete`, `compgen`, `COMP_WORDS`, `COMP_CWORD`, `COMPREPLY`  |
| Completion function | Fish  | `complete -c cmd -a args`, condition flags, subcommand patterns |
| ZLE widget          | Zsh   | `zle -N widget func`, `bindkey` to map keys                     |
| Prompt hook         | Zsh   | `precmd`, `preexec`, `chpwd` via `add-zsh-hook`                 |
| Prompt hook         | Bash  | `PROMPT_COMMAND` (string or array in Bash 5.1+)                 |
| Event handler       | Fish  | `--on-event`, `--on-variable`, `--on-signal`                    |
| Abbreviation        | Fish  | `abbr -a name expansion`, `--function` for dynamic              |
| Parameter expansion | Zsh   | `${(s.:.)var}`, `${var:=default}`, flags and modifiers          |
| Terminal control    | All   | ANSI/CSI escape sequences, `tput`, `stty`                       |
| Signal handling     | All   | `trap` builtin, cleanup patterns, `EXIT`/`INT`/`TERM`           |
| Process management  | All   | Job control (`&`, `wait`, `bg`, `fg`), subshells, coprocesses   |
| Plugin installation | All   | Sourcing strategies, version detection, `ZDOTDIR` loading order |

## Common Mistakes

| Mistake                                               | Correct Pattern                                                |
| ----------------------------------------------------- | -------------------------------------------------------------- |
| Using `echo -e` for escape sequences portably         | Use `printf` or `tput` for portability across shells and OSes  |
| Modifying `PROMPT_COMMAND` with `=` in Bash           | Append with `+=` to avoid overwriting other tools              |
| Defining Fish event handlers in lazy-loaded functions | Place event handlers in config.fish or source them explicitly  |
| Hardcoding terminal capabilities                      | Query via `tput` which respects `TERM` and terminfo            |
| Missing `emulate -L zsh` in Zsh functions             | Always set local options to avoid polluting caller environment |
| Using `$COMP_LINE` splitting instead of `COMP_WORDS`  | Use `COMP_WORDS[$COMP_CWORD]` for reliable word extraction     |
| Not quoting `$@` in wrapper scripts                   | Always use `"$@"` to preserve argument boundaries              |
| Assuming `/bin/sh` is Bash                            | Target POSIX sh for portable scripts, test with `dash`         |
| Using `function` keyword in POSIX scripts             | Use `name() { ... }` syntax for POSIX compatibility            |
| Ignoring `EXIT` trap for cleanup                      | Always set `trap cleanup EXIT` for temp files and state        |

## Delegation

- **Completion testing**: Use `Explore` agent to verify completions interactively
- **Script review**: Use `Task` agent for cross-shell compatibility audits
- **Code review**: Delegate to `code-reviewer` agent

> If the `rust` skill is available, delegate native binary compilation patterns to it. Shell wrappers often invoke Rust-compiled binaries for performance-critical operations.
> If the `cli-power-tools` skill is available, delegate modern CLI utility patterns to it. Many shell plugins wrap tools like `fd`, `ripgrep`, and `fzf`.

## References

- [Zsh integration: ZLE, completions, hooks, parameter expansion](references/zsh-integration.md)
- [Bash integration: readline, completions, PROMPT_COMMAND, shopt](references/bash-integration.md)
- [Fish integration: completions, events, abbreviations, functions](references/fish-integration.md)
- [Terminal control: ANSI/CSI sequences, tput, stty, capabilities](references/terminal-control.md)
- [POSIX scripting: portable patterns, signal handling, process management](references/posix-scripting.md)
- [Plugin distribution: installation scripts, dotfile management, version detection](references/plugin-distribution.md)

© oakoss · MIT · oakoss/agent-skills

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set106

The whole set →
tanstack-devtools tanstack-devtools guides AI coding agents in configuring Query cache, Router, and Form debugging panels across React applications. CX Codex +1 125installs seo-optimizer seo-optimizer — an SEO architecture skill: JSON-LD entities, E-E-A-T signals, topic clusters and a 30-point content audit. Runs in Claude, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode. CX Codex +1 125installs performance-optimizer performance-optimizer provides structured workflows for profiling, caching, and full-stack performance tuning. Helps eliminate slow database queries, optimize bundles, and reduce API latency. CX Codex +1 124installs storybook-stories Writes Storybook stories and interaction tests in CSF3 format. Handles component examples, Chromatic visual snapshot setup, and accessibility checks. CX Codex +1 124installs usability-tester usability-tester plans usability test sessions, evaluates interfaces against heuristic standards, and scores UX friction points using severity formulas. CX Codex +1 122installs react-email Build responsive HTML emails from React Email components and render them as HTML or plain text. Useful for transactional messages and marketing templates. CX Codex +1 122installs rag-implementer rag-implementer guides an agent through a retrieval-augmented generation build, from chunking and embeddings to hybrid retrieval and quality metrics. CX Codex +1 121installs service-worker service-worker guides the coding assistant in configuring Workbox v7.4 caching, offline app shells, background sync, and push notifications. CX Codex +1 121installs

Project sponsors

Companies that keep this analytics open