Brief IA

Claude Code: The Unknown CLI Commands That Change Everything

🛠️ AI Tools·Tom Levy·

Claude Code: The Unknown CLI Commands That Change Everything

Claude Code: The Unknown CLI Commands That Change Everything
Key Takeaways
1Users of Claude Code are discovering hidden CLI commands that optimize their workflow.
2The command 'claude --help' reveals often overlooked but crucial features for efficiency.
3A better understanding of CLI commands prevents unnecessary project session restarts.
💡Why it mattersOptimized use of Claude Code through CLI commands can transform developer productivity by simplifying repetitive tasks.
Le brief IA que lisent les pros

Le brief IA que les pros lisent chaque soir

Les 7 actus IA du jour, décryptées en 5 min. Gratuit.

Inclus dès l'inscription : notre sélection des meilleurs guides & comparatifs IA.

Choisis ton rythme

Gratuit · Pas de spam · Désabonnement en 1 clic

📄
Full Analysis

Claude Code: The Unknown CLI Commands That Change Everything

1. The First Thing That Changed: I Stopped Losing My Sessions

Claude Code automatically saves each session. I simply didn't know how to return to them. Three options solve this problem:

  • claude -c: Resumes the most recent session in this directory.
  • claude -n "auth-refactor": Names a session when you start it.
  • claude -r "auth-refactor" "finish the PR description": Returns to it by name, days later.

The naming part makes this truly usable. Without a name, you get an automatically generated ID like 7c5dcf5d, which works but is impossible to remember. With a name, picking up work three days later requires just one command, and Claude already knows everything about it.

There is a fourth option to be aware of. If you want to resume an old session but are about to try something risky, --fork-session the branch so the original transcription remains intact:

  • claude -r auth-refactor --fork-session

| Option | What It Actually Does | |--------|-----------------------| | claude -c | Resumes your last session in this folder. Full context, no re-explanation. | | claude -n "name" | Names the session so you can find it later without searching for an ID. | | claude -r "name" | Resumes a specific session by name or ID. | | claude --fork-session | Resumes but forks, so the original session remains unchanged. | | claude --from-pr 123 | Opens the session selector filtered by sessions related to a specific pull request. |

Try this now: open a project you were working on yesterday and run claude -c. If you have already used Claude Code in this folder, it will pick up exactly where you left off. This single command makes the difference between a tool you restart every day and one that remembers your project.

2. The One That Changed My Entire Workday: Background Agents

If you need to remember just one thing from this article, it's this.

Adding --bg to any command starts the task as a background agent and immediately returns your terminal to you. Claude keeps working. You keep working. You check back whenever you want.

  • $ claude --bg "investigate why payments.test.js is flaky"

Session started: 7c5dcf5d

To attach: claude attach 7c5dcf5d

To see the logs: claude logs 7c5dcf5d

To stop: claude stop 7c5dcf5d

The moment this hit me was a Monday morning. I started a background agent to audit unknown source code for security issues, then spent the next forty minutes doing my scheduled work in a second terminal. When I returned, I had a complete report waiting for me. I hadn't been sitting there watching a loading indicator.

You can run multiple agents at once. My usual pattern now looks like this:

  • claude --bg "audit the API surface for missing auth checks"
  • claude --bg "find every TODO comment older than six months"

| Command | What It Does | |---------|---------------| | claude agents | Live view of every session, ongoing and completed. | | claude agents --json | Same thing in JSON, so you can process it in a script. | | claude attach <id> | Brings a background session into your current terminal. | | claude logs <id> | Prints recent output without attaching. | | claude stop <id> | Stops an ongoing session. | | claude rm <id> | Removes it from the list. The transcription remains on disk. | | claude respawn <id> | Restarts a session with its conversation intact. | | claude respawn --all | Restarts everything. Useful right after a Claude Code update. |

Another one I took time to notice. The --exec option executes a simple shell command as a background task instead of a Claude session, which is surprisingly handy for long tests:

  • claude --bg --exec 'pytest -x tests/'

If parallel agents interest you on a larger scale, Anthropic has taken this much further with Dynamic Workflows, which can coordinate hundreds of parallel sub-agents in a single session.

3. The Option I Should Have Learned on Day One

-p, short for --print. It executes your request, prints the response, and exits. No interactive session, no waiting for a follow-up.

This may sound boring. What makes it interesting is that it transforms Claude Code from a tool where you sit into something you can redirect:

  • claude -p "what does auth.js actually do"
  • cat error.log | claude -p "summarise these errors by root cause"
  • cat changes.diff | claude -p "review this diff for security issues"
  • claude -c -p "any type errors left?"

Redirection is the part I rely on the most now. Feeding a log file or a diff directly into Claude is faster than describing where the file is and waiting for it to read from disk, and it works on files outside your project folder.

Try this now: find any log file on your machine and run: cat thatfile.log | claude -p “what is going wrong here”. It takes about ten seconds, and it's the fastest way to understand what -p is for.

4. Where I Was Quietly Burning Money

This section exists because of a bill I didn't appreciate.

Claude Code has an effort parameter that controls how much reasoning it applies to a task. I had never touched it, which meant that every trivial task received the same deep thinking treatment as a difficult architectural problem.

  • claude --effort low: small changes, quick questions.
  • claude --effort medium: standard day-to-day coding.
  • claude --effort high: complex refactorings, architectural work.
  • claude --effort ultracode: very high effort with ultracode enabled (v2.1.203+).

Adjusting the effort to the task is the simplest cost lever in the tool. A one-line fix doesn't need maximum effort.

5. The Setting I Had Misconfigured for Months

The permission modes control how much Claude Code does without checking with you first. I operated with the default setting for a long time, approving every file change manually, and assumed it was the only safe option.

This is not the case. There are six modes, and choosing the right one for the task eliminates a lot of friction without giving up control where it matters:

| Mode | What It Allows | |------|----------------| | default | Prompts before every modification and tool usage. | | acceptEdits | Automatically accepts file changes, speeding up the process. |

Brief IA — L'actualité IA en français

L'essentiel de l'actualité de l'intelligence artificielle, décrypté et expliqué chaque jour.