본문으로 건너뛰기
cccskills
무료GitHub에 공개

shell-builtins

Add or modify commands handled inside Crush's embedded shell before they reach the operating system. The guidance covers command routing, input and output streams, exit codes, and cancellation so commands work with pipes, redirection, and hook timeouts.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

Use when creating a new shell builtin command for Crush (internal/shell/), editing an existing one, or when the user needs to understand how commands are intercepted in Crush's embedded shell.

설치 방법 보기

이럴 때 유용합니다

  • Adding a command to Crush's embedded shell
  • Modifying an existing built-in command
  • Supporting pipes and output redirection
  • Implementing cancellation for hook timeouts

포함된 파일(1)

  • SKILL.md3.1 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Shell Builtins

Crush's shell (internal/shell/) uses mvdan.cc/sh/v3 for POSIX shell emulation. Commands can be intercepted before they reach the OS by adding builtins — functions handled in-process.

How Builtins Work

Builtins live in builtinHandler() in internal/shell/run.go. This is an interp.ExecHandlerFunc middleware registered in standardHandlers() before the block handler, so builtins run even for commands that would otherwise be blocked. The same handler chain is shared by the stateful Shell type and the stateless Run entrypoint used by the hook runner, so builtins are available identically in the bash tool and in hooks.

The handler is a switch on args[0]. Each case either handles the command inline or delegates to a helper function.

Adding a New Builtin

  1. Add the case to the switch in builtinHandler() in run.go.
  2. Get I/O from the handler context, not from os.Stdin/os.Stdout. This ensures the builtin works with pipes and redirections:
    case "mycommand":
        hc := interp.HandlerCtx(ctx)
        return handleMyCommand(ctx, args, hc.Stdin, hc.Stdout, hc.Stderr)
    
  3. Implement the handler in its own file (e.g., internal/shell/mycommand.go). The function signature must accept a context.Context as the first parameter, plus args, stdin, stdout, and stderr:
    func handleMyCommand(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) error {
        // args[0] is the command name ("mycommand"), args[1:] are arguments.
        // Write output to stdout, errors to stderr.
        // Return nil on success, or interp.ExitStatus(n) for non-zero exit codes.
    }
    
  4. Poll ctx in every unbounded loop. Builtins that iterate over input, emit values in a generator-style loop, or do any other work that can exceed a few milliseconds MUST check ctx.Err() on each iteration and return it verbatim when non-nil. Hook timeouts rely on this: an unbounded builtin that never polls ctx cannot be interrupted by a hook's timeout_sec, and the hook runner will have to abandon the goroutine (see internal/hooks/runner.go). Returning ctx.Err() (not interp.ExitStatus(n)) lets callers distinguish "command exited non-zero" from "we ran out of time".
    for _, item := range items {
        if err := ctx.Err(); err != nil {
            return err
        }
        // ... process item
    }
    
  5. Return values: return nil for success, interp.ExitStatus(n) for non-zero exit codes, or ctx.Err() on cancellation. Write error messages to stderr before returning.
  6. No extra wiring needed — builtinHandler() is already registered in standardHandlers().

Existing Builtins

CommandFileDescription
jqjq.goJSON processor using github.com/itchyny/gojq

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Add or edit skills bundled with Crush, following guidance on file placement, required metadata, compile-time embedding, and discovery tests. It also explains how built-in skills are loaded and how user skills override them.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Adding a skill bundled with Crush
  • Editing an existing built-in skill
  • Understanding skill discovery and overrides
charmbracelet/crush2.9만2026년 10월 19일 업데이트

Configure Crush with Bash or JSON files to choose AI providers and models, connect external tools, set permissions, and adjust behavior. Understand how project and global settings combine when customizing your working environment.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Set up AI providers and model selections
  • Connect MCP servers and language servers
  • Configure tool permissions and execution hooks
charmbracelet/crush2.9만2026년 10월 19일 업데이트

Create, configure, and troubleshoot Crush hooks, commands that run before tool execution. Use them to block or approve calls, rewrite tool input, or add context for the agent, with guidance on configuration and troubleshooting.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Blocking destructive shell commands
  • Automatically approving read-only tools
  • Adding editing reminders for the agent
charmbracelet/crush2.9만2026년 10월 19일 업데이트

jq

무료

Extract fields, filter records, and reshape JSON from API responses, configuration files, or logs using Crush’s built-in jq. Get help writing and debugging transformations, constructing new JSON, and formatting output for other commands.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Extract selected fields from API responses
  • Filter JSON arrays by conditions
  • Reshape configuration data or construct JSON
charmbracelet/crush2.9만2026년 10월 19일 업데이트

charmbracelet의 스킬 모두 보기

이 스킬의 문제 신고