> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# staged

The `rs staged` command uses [lint-staged](https://github.com/lint-staged/lint-staged) to run tasks against files staged in Git.

`rs staged` can run linters, formatters, or other checks on staged files before committing code.

A common pattern is to pair `rs staged` with [`rs hooks`](/guide/cli/hooks.md) and run staged-file tasks from a `pre-commit` hook.

## Usage

```bash
rs staged [options]
```

The command loads the staged-file tasks registered with [`define.staged()`](/guide/configuration.md#define-staged).

## Options

### `--allow-empty`

`--allow-empty` allows an empty commit when tasks revert all staged changes.

```bash
rs staged --allow-empty
```

### `--concurrent`

`--concurrent` controls how many tasks may run at the same time. It accepts `true`, `false`, or a positive integer.

When the option is omitted, it defaults to `true`, so `rs staged` runs tasks concurrently without a fixed limit. Set it to `false` to run one task at a time, or use a positive integer to limit the number of concurrent tasks.

```bash
# Use the default: run tasks concurrently without a fixed limit
rs staged
rs staged --concurrent true

# Run one task at a time
rs staged --concurrent false

# Run at most four tasks at a time
rs staged --concurrent 4

# -p is shorthand for --concurrent
rs staged -p 4
```

For example:

```ts
define.staged({
  '*.ts': ['rs lint --fix', 'rs fmt'],
  '*.md': 'rs fmt',
});
```

With concurrency enabled, `rs fmt` for Markdown files may run while TypeScript files are being linted. For TypeScript files, `rs fmt` starts only after `rs lint --fix` finishes.

### `--cwd`

`--cwd` sets the working directory used to run all tasks.

```bash
rs staged --cwd packages/app
```

### `--debug`

`--debug` (or `-d`) prints additional debug information.

```bash
rs staged --debug
```

### `--no-stash`

`--no-stash` disables the backup stash and automatic reversion when a task fails.

```bash
rs staged --no-stash
```

### `--quiet`

`--quiet` (or `-q`) disables lint-staged's own console output.

```bash
rs staged --quiet
```

### `--relative`

`--relative` (or `-r`) passes file paths relative to the working directory to tasks.

```bash
rs staged --relative
```

### `--verbose`

`--verbose` (or `-v`) shows task output even when tasks succeed; by default, only output from failed tasks is displayed.

```bash
rs staged --verbose
```

### `--help`

`--help` (or `-h`) displays the command's usage and options.

```bash
rs staged --help
```

## Configuration

Configure staged-file tasks through [`define.staged()`](/guide/configuration.md#define-staged) in the [Rstack configuration file](/guide/configuration.md#configuration-file). It accepts the standard [lint-staged configuration](https://github.com/lint-staged/lint-staged#configuration):

```ts title="rstack.config.ts"
import { define } from 'rstack';

define.staged({
  '*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}': ['rs lint --fix', 'rs fmt'],
  '*.{json,md,mdx,css,scss,less,html,yml,yaml}': 'rs fmt',
});
```
