Loading learning content…
Loading learning content…
Use Claude Code's Bash tool to run tests, install packages, query databases, and automate shell tasks.
Read through the lesson, mark it complete when the concept is clear, then move to the next lesson in the sequence or jump back to the module map.
Claude Code can run shell commands on your machine via the Bash tool. This enables it to run tests, install packages, query databases, check logs, and interact with external services — all within a session.
Anything you could run in a terminal. Common patterns:
Run the test suite and show me which tests are failing.
Install the zod package and update package.json.
Check the git log for the last 10 commits and summarize what changed.
Before running any shell command, Claude shows you the exact command it plans to execute. You approve or reject it. This prevents surprise side effects.
For frequently-approved commands, you can add them to your allowed list in .claude/settings.json:
{
"allowedTools": ["Bash(npm test)", "Bash(npm run lint)"]
}
The most powerful use of the Bash tool is verification loops:
Make the change, then run the tests to verify nothing broke.
Claude will edit the code, run the test suite, read the output, and either report success or iterate on the fix. This tight loop is where Claude Code shines over static code generation tools.
Claude can query your local database to verify state:
Run a query to check how many users were created in the last 24 hours.
It will use whatever CLI tool is available (psql, sqlite3, mysql) and interpret the results.
rm, drop, or DELETE--dangerously-skip-permissions only in sandboxed CI environments, never locallyClaude inherits your shell's environment variables. If your project needs .env loaded, start the session with source .env && claude or use direnv.