# Compound Command

> Commands joined with && or a pipe, each part checked on its own.

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** && command, chained command

## Think of it like

It is like a ticket for two rides. Each ride still checks it.

## Definition

A compound command joins two or more commands with &&, ||, ;, a pipe or a new line. Claude Code splits it before it checks your rules. Every part must be allowed on its own, or you are asked. So Bash(npm test *) does not let npm test && rm -rf build run. A deny rule that matches any one part stops the whole thing.

## Example

Claude writes cd api && npm test. The cd is safe and npm test is allowed, so it runs. Had it ended in git push, Jack would be asked.

## Example code

```console
$ npm test && git push
# npm test matches an allow rule
# git push does not, so Claude Code asks
```

One part passes, one part needs you.

## Why it matters

Without the split, one safe command could sneak a bad one in behind it.

## Common mistake

Saving a rule for the whole joined line. Claude Code saves one rule per part instead.

## Three principles

- **Split first.** &&, ||, ;, pipe.
- **Each part must pass.** Or it asks.
- **Any deny wins.** For the whole.

## Related terms

- [Bash Permission Rule](https://learn.benibix.com/term/ai/bash-permission-rule)
- [Read-Only Command](https://learn.benibix.com/term/ai/read-only-command)
- [Command Wrapper](https://learn.benibix.com/term/ai/bash-command-wrapper)

![A command joined with && is split, and every part must pass on its own.](https://learn.benibix.com/diagrams/permission-compound-command.svg)

---

Source: https://learn.benibix.com/term/ai/bash-compound-command
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
