Basic Commands and How to Talk to Claude
Getting Started: Basic Commands and How to Talk to Claude
Basic Commands and How to Talk to Claude
Series: Claude Learning Journey · Getting Started
The CLI has a small surface area of commands, but they are worth knowing cold. These are the controls for navigating sessions, managing context, and directing Claude’s behaviour when you need to redirect or intervene.
Core CLI commands
claude — start an interactive session
claudeclaude -p "prompt" — run a single prompt and exit
claude -p "What does this function do?" < mycode.pyThis is useful for piping content through Claude or running one-off queries without entering interactive mode.
claude --agent — start an agentic session with tool access
claude --agentclaude --print — like -p but always writes to stdout (useful in scripts)
claude --print "Summarise this: $(cat changelog.txt)"exit or Ctrl-C — leave the current session
> exit/clear — clear conversation history within a session
> /clearThis resets the conversation back to empty without ending the session. Useful when you want to start fresh but keep the same Claude instance.
How to write good prompts
Good prompts are specific about three things: the task, the format, and the constraints.
The task: Tell Claude what to produce. “Write a test for the login function” is better than “test this.”
The format: Tell Claude how to return the result. “Return a JSON object with keys passed (boolean) and failures (array of strings)” gives you something you can parse. “Give me a summary” gives you prose you have to read.
The constraints: Tell Claude what to respect. “Do not use external libraries beyond what is already installed” or “keep it under 50 lines” or “use type hints throughout.”
Correcting Claude
When Claude gets something wrong, be direct. Do not be vague about the error:
Bad: “That is not right.”
Good: “The sort order is wrong — it should be descending by count, not ascending. The current output has item B at the top when item A has a higher count.”
The second version tells Claude exactly what to fix and what the correct behaviour is. Being direct produces faster, more accurate corrections.
Asking for alternatives
If Claude produces something that is technically correct but not what you wanted, ask for alternatives rather than trying to specify the fix:
You: "This works but feels clunky. Can you show me a more idiomatic approach in Python?"Claude: [provides a cleaner version]Claude has seen a lot of code in training. It usually has multiple ways to solve a problem and will show you different approaches if you ask.
Multi-turn refinement
Do not try to get the perfect answer in one shot. Multi-turn is the intended usage pattern:
- Ask for a first draft
- Review it
- Give specific feedback (“this part is confusing, can you rewrite it”, “the error handling here is too broad”, “I need this to handle null inputs”)
- Repeat until satisfied
This is not a weakness of the model. It is how the interaction is designed to work.
Commands within a session
Inside an interactive session, several slash commands are available:
/help— show available commands and shortcuts/clear— clear conversation history/model— switch between models mid-session/context— show current context usage
Use /help to see what is available in your version.
What not to do
Do not paste API keys or secrets into the conversation. The conversation may be logged by Anthropic depending on your account settings. Use environment variables, not chat.
Do not assume Claude knows your project without providing context. It has no access to your codebase unless you give it file paths to read or attach files.
Do not ask vague questions expecting specific answers. “Should I use a database here?” is not a useful question. “What are the trade-offs of PostgreSQL vs DynamoDB for a write-heavy event log with strong consistency requirements?” gives you something concrete to work with.
Try it yourself
Open a Claude session and try the following in sequence:
- Ask a vague question, notice the vague answer
- Ask the same question with specific constraints, notice the difference
- Ask for a second approach, compare the two
- Use
/clearand ask again — notice that Claude does not remember the previous exchange
This demonstrates the input-quality-to-output-quality relationship directly.
What’s Next
With the basics covered, Stage 2 dives into the workflows that make you productive. Next up: prompt engineering — the skill that multiplies everything else you do with Claude.
Part of the Claude Learning Journey series · Next: Prompt Engineering That Actually Works