Menu
Claude Code Hacks: Automate Bash Tool Installs (Game-Changer)

Claude Code Hacks: Automate Bash Tool Installs (Game-Changer)

Chris Hay

44 views 11 months ago Save 12 min 6 min read

Video Summary

Claude Code's integration with the bash shell offers significant flexibility, allowing it to execute commands directly from the shell, such as date for time or curl for internet access. This capability extends Claude Code's functionality without requiring dedicated MCP servers for every action. By leveraging bash scripting, users can create custom tools, host them on platforms like GitHub, and have Claude Code automatically install and execute them.

This process involves a simple installation script (e.g., install.sh) and an LLM.ext file, which serves as a guide for AI agents detailing tool usage, dependencies, and execution. The video demonstrates installing and running a Wikipedia search tool and a "hello world" tool, showcasing how Claude Code fetches the script, installs it into the local bin directory, and executes it. While bash scripting can be complex, especially with features like conditional logic and JSON parsing using jq, it provides a lightweight alternative to more involved methods for creating extensible AI agent tools.

Short Highlights

  • Claude Code can access the bash shell, enabling it to run commands like date and curl.
  • Bash scripts can be hosted on GitHub and automatically installed and executed by Claude Code.
  • The LLM.ext file provides instructions for AI agents on how to use these bash tools.
  • The process involves using a curl command to fetch an install.sh script, which then installs the tool.
  • The jq command is utilized for processing JSON data within these bash scripts.

Key Details

Leveraging Bash Shell in Claude Code [0:00]

  • Claude Code has built-in access to the bash shell, offering significant flexibility.
  • This allows for extending Claude Code's capabilities without always needing an MCP server.
  • Examples include using the date command for time and curl for internet access.
  • Bash, being a scripting language, enables the creation and automatic installation/execution of custom tools.

"Now that gives huge amount of flexibility to Claude code because if you need to extend things you don't always need to add an MCP server."

Demonstrating Bash Integration: Current Time [0:48]

  • When asked for the current time, Claude Code, lacking a dedicated time tool, uses the bash shell.
  • It executes the date command, demonstrating its ability to run shell commands.

Fetching Web Content with curl and jq [2:09]

  • The fetch tool can be combined with bash capabilities.
  • The example shows fetching AI news articles from techmeme.com using curl.
  • Claude Code requires user permission to fetch external content.
  • It successfully retrieves and lists the top five AI articles.

"So if I can then create scripts that do interesting things and cloud code has the ability to execute bash scripts then technically I could host my bash scripts in something like my GitHub repo and have it use the fetch command to pull the command install it and then execute that."

Automating Tool Installation from GitHub [3:24]

  • The core concept is hosting bash scripts on GitHub and having Claude Code install and run them.
  • This is demonstrated by running a command that points to a GitHub repository containing bash tools.
  • Claude Code recognizes the need to install a "wiki search" tool.
  • It uses curl to fetch an install.sh script from the repository.
  • The script installs the wiki.search tool into the user's local bin directory.
  • After installation, Claude Code executes the tool using bash, piping the query through wiki.search and jq.
  • The result of the Wikipedia search is then returned.

"So you see here it's offering to do the install. It's doing you do a curl. Um, it's going to pull the this thing called an install.sh?"

Installing and Executing the "Hello World" Tool [6:27]

  • The process is repeated for a "hello world" tool.
  • Claude Code identifies the need to install this tool as well.
  • The install.sh script places the hello_world executable in the local bin directory.
  • Claude Code then executes the hello_world tool, demonstrating seamless integration.

"It's installed into my local bin directory the wiki.search tool."

GitHub Repository Structure and Tool Details [8:48]

  • The GitHub repository (chrisheyuk-chuck-ai/bashtools) houses the bash scripts and installation logic.
  • The wiki.search tool is a bash script that defines its usage, schema, and dependencies (jq, curl).
  • It reads input, uses jq to extract the query, URL-encodes it, performs the search, and outputs results (title, page, snippet).
  • The hello_world tool is simpler, taking JSON input, extracting a name, and generating an output message.
  • It also uses jq for JSON processing.
  • The install.sh script is crucial for cross-platform installation (Windows, Ubuntu, macOS).

"So you just need to go into um you just need to go into the tools wiki and then there is a search and as you can see this is just a bash script right."

jq for JSON Processing [13:43]

  • jq is a powerful command-line JSON processor.
  • It's used to parse, filter, and transform JSON data.
  • Examples show how to output all JSON, extract specific fields (like "name" or "age"), and create custom JSON objects.

"jq is basically a powerful command-line JSON processor."

Creating a Unified JSON Script (demojson.sh) [17:56]

  • A script is created to handle both plain text input and structured JSON output.
  • set -euo pipefail is used for error handling and pipeline robustness.
  • cat is used to read multi-line input, including JSON.
  • jq is used to extract data and construct the output JSON.
  • This demonstrates how to create a more sophisticated tool that integrates with Claude Code's expected input/output formats.

"So basically what it's saying there is if you get an error in the pipeline, you you should fail the whole pipeline."

Benefits and Considerations of Bash Scripting [22:09]

  • Bash scripting offers a lightweight approach for simple tools without the overhead of MCP services.
  • It provides flexibility for building agents and creating a repository of tools.
  • Unlike compiled executables, bash scripts are interpretable, making them easier to inspect.
  • The speaker acknowledges that bash scripting can be complex and error-prone (e.g., syntax, spacing).
  • LLM.ext is presented as a standard for AI agents, providing guidance on tool usage and installation.

"But you know, if you want to create something simple um you know, without an overhead there, it just gives you a different way of doing things."

LLM.ext - The AI Agent's Guide [24:45]

  • LLM.ext files are markdown files that provide instructions for AI agents.
  • They detail installation requirements, dependencies, and usage guides for tools.
  • This standardized format helps agents understand and interact with new tools.

"This is probably the trick to this. So um this is llm.ext is a basically a standard for AI agents."

Other People Also See