Skip to content
PD
Claude Code

Claude Code CLI: Commands, Flags and Modes

How Claude Code starts, what the permission modes actually mean, which flags earn their keep in daily work, and what belongs in project configuration instead of being retyped.

All articles in the guide Claude Code · 13

Claude Code starts with a single command in the project directory. Everything else is a way of specifying what permissions it runs with, which model it uses, and whether it continues an earlier conversation.

Starting and the basic commands

The usual flow is to open the project directory and start the agent. It comes up interactive: you state the task, it works, you watch what it does.

Three things you need almost immediately:

  • Resume the last session in this directory, after an accidental exit or when picking work back up.
  • Pick a session from the list when you need one from last week specifically.
  • Non-interactive mode, where the task arrives as one string and the result goes to stdout. This is how the agent gets embedded in scripts and CI.

Inside a session, commands start with a slash. Three are needed almost daily: clearing context for a new task, compacting context when it approaches the limit, and switching model mid-flight.

Permission modes

This is the main setting, and it is about safety rather than convenience.

Ask every time. The agent shows the command and waits. Slow, but you see every action. A sensible mode on an unfamiliar project.

Allow from a list. You describe once what needs no confirmation - running tests, building, reading files - and everything else still asks. This is the working mode on your own project.

Allow everything. The agent stops asking. It saves a great deal of time and is a bad idea outside an isolated environment: it has shell access, which means access to everything you have. That mode belongs in a container or on a separate machine - see sandbox your coding agent.

A separate note on the network: an agent that can make network requests can also send file contents outward. On a project with sensitive data you constrain that by configuration, not by instruction.

Flags that earn their keep

  • Model selection. Different tasks want different models, and this is the most direct lever on speed and spend. Details in the models article.
  • Permission mode, set at launch so you are not toggling it by hand.
  • Session resume, returning to the last conversation instead of restating context.
  • A step limit in non-interactive mode - insurance against an agent that loops and burns tokens.
  • Output format for non-interactive mode: structured output is far easier to parse in a script than prose.

What belongs in configuration

Anything you retype more than twice. In a project that is three things.

A project description file. The agent reads it at the start of every session. It should hold what the agent would otherwise guess: how tests are run, the build commands, code conventions, what must never be done in this repository. One good file saves more time than any flag.

Project settings. Allowed commands, default mode, model. They live in the project and behave identically for the whole team - see Claude Code for teams.

Skills for repeatable procedures: how a release is cut here, how a new entity is added, how a migration is written. It is a description of a process that the agent picks up when the task resembles it.

A working rule: if you are explaining the same thing to the agent for the third time, that explanation belongs in a file, not in your message.

Next

From here it makes sense to understand context spend and write a first skill. The overview is in the Claude Code guide.

FAQ

How do I resume a previous Claude Code session?

Starting with the continue flag brings back the last conversation in the current directory, and picking from the session list returns you to a specific one. One detail matters: sessions are tied to the directory, so starting from another folder shows a different history.

Can I run Claude Code from a script, without a conversation?

Yes, through non-interactive mode: the command takes the task as a single string, runs it and prints the result to stdout. That is how it gets embedded in CI and git hooks. Permissions must be set in advance there, since there is nobody to ask.

What should I do when the agent forgets what we were discussing?

Context filled up and part of the history was compacted away. That is normal for a long session, but answer quality drops with it. The right response is not to push on but to start a clean session scoped to one task and give it only the files that matter.

More on this topic