Implement the bash tool


title: "Build Your Own Redis, Git & SQLite From Scratch" source: "https://app.codecrafters.io/courses/claude-code/stages/oq5" author: published: created: 2026-05-31 description: "Advanced programming challenges for experienced engineers. Rebuild real production tools like Redis, Git, and SQLite from scratch in your IDE." tags: - "clippings"


Implement the bash tool #oq5

In-progress

Upgrade

Your Task

In-progress

Easy

In this stage, you'll add support for the Bash tool.

The Bash Tool

The Bash tool enables the LLM to run shell commands. It gives the model direct access to the command line to perform actions like deleting files, creating directories, or running scripts.

You'll need to advertise the Bash tool in your request and execute it when the model requests it.

Here is an example of the Bash tool's specification:

{
  "type": "function",
  "function": {
    "name": "Bash",
    "description": "Execute a shell command",
    "parameters": {
      "type": "object",
      "required": ["command"],
      "properties": {
        "command": {
          "type": "string",
          "description": "The command to execute"
        }
      }
    }
  }
}

Executing the Bash Tool

When the model requests a Bash tool call:

  1. Parse the arguments to extract the command
  2. Execute the command using your language's shell execution capabilities (e.g., subprocess.run() in Python, child_process.exec() in Node.js)
  3. Capture both stdout and stderr from the command
  4. Return the command output (or an error message if it failed) to the model as a tool message

For example, if the command is rm README_old.md, execute it and return the result (which will be empty if successful).

Tests

The tester will create three files:

The tester will then execute your program like this:

$ ./your_program.sh -p "Delete the old readme file."
Deleted README_old.md

The tester will verify that:

Notes

How to pass this stage

1

Write code to pass this stage

Head over to your editor / IDE and implement your solution.

If you want a quick look at what functions to use or how to structure your code, we recommend looking at Code Examples.

2

Submit code

To run tests, make changes to your code and run the submit command:

codecrafters submit # Visit https://codecrafters.io/cli to install

Test Runner:

Ready to run tests

Hints

Filter by Python

Write

Preview

Python LEADERBOARD

Complete this stage to hit #8636

Ready to run tests

Show logs