Skip to main content
Part 3 of 14 in Claude Code for Java DevelopersSeries overview →

Claude Code for Java: Shortcuts and Commands You Will Use Every Day

Learn the keys and commands that make a Claude Code session fast: stop, undo, resume, background, trim context and switch model, with real runs on a Spring Boot project.

By now you can ask Claude Code a good question. The next step is speed. Most of a working session is a few keys and a few commands, used again and again.

In this part you will run one session from start to finish. You start it with a name, ask a question, get an edit you did not want, undo it, leave, come back, and add a test.

What you will do​

You will drive one session on the orders-service project. First you name the session and ask a question about it. Then a vague prompt makes Claude Code change a file you did not ask about, and you undo that change.

After that you leave the session and resume it. Last, you ask for one precise test and check it yourself. Along the way you meet the keys and commands from Figure 1.

In our test run, Claude Code reported 10.6 seconds for the first answer, 4.6 seconds for the answer after resuming, and 40.6 seconds for the test edit with a test run. Those are Claude Code's own numbers. Your reading and review time comes on top, so allow 30 to 45 minutes. That figure is our guess, not a measurement.

You need Parts 1 and 2, or the part-03/start folder from the example repository. You also need JDK 25, Git, and Claude Code signed in.

Every run below used Claude Code 2.1.316 on 31 October 2026, on Windows 11 with Git Bash, JDK 25.0.5 and Spring Boot 4.1.2. We ran them non-interactively, with claude -p. A key press cannot happen in that mode, so the key behavior comes from the official docs. Where that is the case, the text says "from the docs".

The keys and commands, in one picture​

Figure 1 groups the keys by what you are trying to do. The orange keys are for when something goes wrong. The lavender keys change how Claude Code works.

The keys you use every dayFour groups of keys. Stop and undo: Esc stops the response, Esc Esc opens the rewind menu when the prompt is empty, Ctrl+C interrupts or clears the input. Mode and model: Shift+Tab cycles the permission mode, Alt+P switches the model. Type and search: ! runs a shell command, @ mentions a file, Ctrl+R searches history, Ctrl+G opens your editor. Background and leave: Ctrl+B backgrounds a running command, Ctrl+D exits when pressed twice. On macOS, Alt is Option.STOP AND UNDOEscstop the responseEsc Escrewind menuCtrl+Cinterrupt or clearMODE AND MODELShift+Tabcycle the modeAlt+Pswitch modelTYPE AND SEARCH!shell command@mention a fileCtrl+Rsearch historyCtrl+Gopen your editorBACKGROUND, LEAVECtrl+Bbackground itCtrl+Dexit (press twice)when it goes wrongchanges how it worksWindows and Linux keys. On macOS, Alt is Option.The keys you use every dayFour groups of keys. Stop and undo: Esc stops the response, Esc Esc opens the rewind menu when the prompt is empty, Ctrl+C interrupts or clears the input. Mode and model: Shift+Tab cycles the permission mode, Alt+P switches the model. Type and search: ! runs a shell command, @ mentions a file, Ctrl+R searches history, Ctrl+G opens your editor. Background and leave: Ctrl+B backgrounds a running command, Ctrl+D exits when pressed twice. On macOS, Alt is Option.STOP AND UNDOEscstop the responseEsc Escrewind menuCtrl+Cinterrupt or clearMODE AND MODELShift+Tabcycle the modeAlt+Pswitch modelTYPE AND SEARCH!shell command@mention a fileCtrl+Rsearch historyCtrl+Gopen your editorBACKGROUND, LEAVECtrl+Bbackground itCtrl+Dexit (press twice)Windows and Linux keys. On macOS, Alt is Option.
Figure 1: The keys you use every day, in four groups. Orange keys are for when something goes wrong.

Here is what each one does. This table is from the interactive mode page, read on 31 October 2026. Keys on macOS use Option where the table says Alt, and macOS needs Option set as Meta in your terminal for the Alt keys.

KeyWhat the docs say it does
Esc"Stop the current response or tool call mid-turn so you can redirect. Claude keeps the work done so far." On a permission prompt, it declines the action.
Esc twiceWith text in the prompt, clears it and saves the draft to history. With an empty prompt, opens the rewind menu.
Ctrl+CInterrupts a running operation. With nothing running, the first press clears the input and a second press exits.
Shift+TabCycles default (shown as Manual), acceptEdits, plan, and, when available, bypassPermissions and then auto. On Windows without VT input mode, the key is Alt+M.
Alt+PSwitches the model without clearing your prompt.
! at the startShell mode. Runs a command, adds its output to the session, and Claude responds to it.
@File path mention.
Ctrl+RReverse search of your command history.
Ctrl+GOpens your prompt in your default text editor.
Ctrl+BSends a running Bash command or agent to the background. In tmux, press it twice.
Ctrl+DExits. The first press shows a hint. A second press within 800 ms exits.
? on an empty promptShows the shortcut panel.

Two more are worth knowing. Type a message and press Enter while Claude Code works, and it queues the message instead of interrupting. Ctrl+S stashes the text you have typed and brings it back on a second press.

Start a session you can find again​

Give the session a name when you start it. A name is easier to remember than a long ID. From the sessions page, read on 31 October 2026, you name a session at startup with claude -n <name>, or inside it with /rename <name>.

Set up the project as in Part 2:

cp -r examples/claude-code-java/part-03/start orders-service
cd orders-service
git init -b main
git add -A && git commit -m "start of part 3"
git switch -c session-tour

In an interactive session you would now type claude -n orders-tour. We used claude -p with the same -n flag and plan mode, which is read only:

Type into Claude Code

In three sentences, what does OrderService.create do, and which tests cover it?

Explore, in a named sessionNon-interactive run (claude -p), Claude Code 2.1.316, trimmed
$ claude -p "In three sentences, what does OrderService.create do, ..." --permission-mode plan -n orders-tour

`OrderService.create` (`OrderService.java:24`) builds an `Order` from the request's customer email and items and sums the line totals into a subtotal. It gives a 10% discount when the subtotal is 100.00 or more, applies 20% tax to the discounted amount, and rounds everything to 2 decimals (half-up). It then sets the amounts on the order and saves it through the repository, all in one transaction.

`OrderServiceTest` covers it directly with a mocked repository, in three tests:
- `addsTwentyPercentTaxToSmallOrders`: tax on a small order with no discount.
- `appliesTenPercentDiscountBeforeTax`: a 200.00 subtotal is discounted, and a 90.00 subtotal is not.
- `appliesDiscountAtExactlyOneHundred`: the discount applies at exactly 100.00.

`OrderControllerTest` also calls it indirectly through `POST /orders` requests. I only searched that file for the POST calls and didn't read its assertions, so I can't say what it checks.

Notice the last sentence again. It names what it did not read: the assertions in OrderControllerTest. Good. The first answer changed nothing.

The edit you did not ask for​

Now we do something careless on purpose. We resume the same session by name and give it a vague order:

Type into Claude Code

Tidy up OrderService.

The vague prompt and its answerNon-interactive run (claude -p), Claude Code 2.1.316, trimmed
$ claude -p "Tidy up OrderService." --resume orders-tour --permission-mode acceptEdits

I tidied `OrderService` by moving the pricing math out of `create` into a new private method, `applyPricing(Order)`. `create` now builds the order, calls `applyPricing`, and saves.

The pricing logic itself is unchanged, so behavior should be the same. I haven't run `OrderServiceTest` or any other tests, so that's unconfirmed.

I left `findAll`, `findById` and `money` alone.

Look at the answer first. It did a refactor. It moved the pricing math into a new method. It also told us, honestly, that it had not run the tests.

Now look at the diff. We did not pass the diff through /diff here, because we ran non-interactively. git diff shows the same changes:

diff --git a/src/main/java/com/agentworks/orders/OrderService.java b/src/main/java/com/agentworks/orders/OrderService.java
index d179e22..d81a77e 100644
--- a/src/main/java/com/agentworks/orders/OrderService.java
+++ b/src/main/java/com/agentworks/orders/OrderService.java
@@ -25,17 +25,7 @@ public class OrderService {
Order order = new Order(request.customerEmail());
request.items().forEach(i -> order.addItem(new OrderItem(i.productName(), i.quantity(), i.unitPrice())));

- BigDecimal subtotal = order.getItems().stream()
- .map(OrderItem::lineTotal)
- .reduce(BigDecimal.ZERO, BigDecimal::add);
- // Subtotals of 100 or more (before tax) get 10 percent off, applied before tax.
- BigDecimal discount = subtotal.compareTo(DISCOUNT_THRESHOLD) >= 0
- ? money(subtotal.multiply(DISCOUNT_RATE))
- : money(BigDecimal.ZERO);
- BigDecimal taxable = money(subtotal).subtract(discount);
- BigDecimal tax = money(taxable.multiply(TAX_RATE));
-
- order.setAmounts(money(subtotal), discount, tax, taxable.add(tax));
+ applyPricing(order);
return repository.save(order);
}

@@ -49,6 +39,20 @@ public class OrderService {
return repository.findById(id).orElseThrow(() -> new OrderNotFoundException(id));
}

+ private static void applyPricing(Order order) {
+ BigDecimal subtotal = order.getItems().stream()
+ .map(OrderItem::lineTotal)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+ // Subtotals of 100 or more (before tax) get 10 percent off, applied before tax.
+ BigDecimal discount = subtotal.compareTo(DISCOUNT_THRESHOLD) >= 0
+ ? money(subtotal.multiply(DISCOUNT_RATE))
+ : money(BigDecimal.ZERO);
+ BigDecimal taxable = money(subtotal).subtract(discount);
+ BigDecimal tax = money(taxable.multiply(TAX_RATE));
+
+ order.setAmounts(money(subtotal), discount, tax, taxable.add(tax));
+ }
+
private static BigDecimal money(BigDecimal value) {
return value.setScale(2, RoundingMode.HALF_UP);
}

The behavior looks the same. That is not the point. We asked for "tidy up", and it chose a restructure. Part 7 covers refactoring on purpose, with a plan and small steps. Here we want to practice the undo, so we reject it.

The undo ladder​

Four ways to take something back, from least work to most. Figure 2 shows them. Use the first one that is enough.

The undo ladderFour rungs from least work to most work. 1 Decline: at the permission prompt press Esc or pick No; nothing has run yet. 2 Stop: press Esc while Claude Code works; it keeps the work done so far and you can redirect it. 3 Rewind: press Esc twice on an empty prompt or run /rewind; it restores Claude Code's file edits, the conversation, or both. 4 Git: git restore, git switch or a reset to a commit; it covers anything you committed. If one rung is not enough, go one rung down. Commit before a big prompt so the last rung always works.LEAST WORKMOST WORK, MOST RELIABLEDeclineat the permission prompt:press Esc, or pick Nocovers: nothing ran yet1StopEsc while it works.You can redirect it.covers: the current turn2RewindEsc Esc, or /rewind.Pick a point to go back to.covers: Claude's file edits3Gitgit restore, git switch,or reset to a commit.covers: anything committed4not enough? go one rung downCommit before a big prompt, so rung 4 always has something to go back to.The undo ladderFour rungs from top (least work) to bottom (most work). 1 Decline at the permission prompt with Esc or No. 2 Stop with Esc while it works. 3 Rewind with Esc Esc or /rewind, which restores Claude Code's file edits, the conversation, or both. 4 Git: restore or switch to what you committed. If one rung is not enough, go one rung down. Commit before a big prompt.LEAST WORKDeclineat the permission prompt:press Esc, or pick Nocovers: nothing ran yet1StopEsc while it works.You can redirect it.covers: the current turn2RewindEsc Esc, or /rewind.Pick a point to go back to.covers: Claude's file edits3Gitgit restore, git switch,or reset to a commit.covers: anything committed4MOST WORK, MOST RELIABLECommit before a big prompt, so the last rungalways has something to go back to.
Figure 2: The undo ladder. Use the first rung that is enough. Commit before a big prompt so the last rung always works.

1. Decline. When Claude Code asks permission to edit or run something, you can say no. From the docs: on a permission prompt, Esc declines the action, the same as No without a comment. Nothing has run yet.

2. Stop. Press Esc while it works. It stops the current response or tool call and keeps the work done so far. Then you type a correction.

3. Rewind. Press Esc twice on an empty prompt, or type /rewind. The checkpointing page, read on 31 October 2026, lists these menu choices: Restore code and conversation, Restore conversation, Restore code, Summarize from here, Summarize up to here, and Never mind. We did not capture this screen in our runs.

Rewind has limits, and the docs list them:

  • It tracks Claude's file edits. Once Claude has edited a file with its edit tools, /rewind also undoes later Bash changes to that file.
  • A file that only a Bash command changed "isn't tracked and stays as it is". Use Git for that.
  • Edits you make yourself outside Claude Code are normally not captured.
  • The docs say checkpoints are not a replacement for version control.

4. Git. The last rung always works, if you committed first. Our tidy-up changed one file, so we restored it:

git restore src/main/java/com/agentworks/orders/OrderService.java
git status --short

git status --short printed nothing. The working tree matched our last commit again.

This is why we commit before any big prompt. Rung 4 is only as good as your last commit.

Come back later​

You can leave a session and return to it with its history. Ours had just lived through an edit and an undo. Does it know?

From the sessions page, these are the ways back:

CommandWhat it does
claude --continueReopens the most recent session in the current directory.
claude --resumeOpens the session picker.
claude --resume <name>Resumes the named session directly.
/resumeSwitches to another session from inside a session.

In the picker, per the docs, Up and Down move, Enter resumes, Space previews, Ctrl+R renames, and typing starts a search. Ctrl+A shows sessions from all projects, and Ctrl+B filters to the current Git branch.

One catch for scripts. The docs say sessions created with claude -p stay out of the picker and out of plain claude --continue. You can still resume one by ID or name. And claude -p --continue includes them. We resumed ours by name:

Type into Claude Code

I undid your tidy-up with git. Without editing anything, tell me in two sentences what we did in this session and what state OrderService is in now.

Resumed by name, after the undoNon-interactive run (claude -p), Claude Code 2.1.316, trimmed
$ claude -p "I undid your tidy-up with git. Without editing anything, ..." --resume orders-tour --permission-mode plan

We looked at `OrderService.create` and its tests (it computes subtotal, 10% discount at 100.00 or more, then 20% tax, and `OrderServiceTest` covers it). Then I tidied it by extracting the pricing math into a private `applyPricing` method, without running tests. Since you reverted that with git, `OrderService` should be back to its original form, with the pricing logic inline in `create` and no `applyPricing` method, though I haven't re-read the file to confirm.

It remembered both steps. And it was honest about what it did not know: "though I haven't re-read the file to confirm." It had no way to see our git restore, so it inferred the result. Always check the files yourself. Do not take the summary's word.

We also tried claude -p --continue:

Resumed with --continueNon-interactive run (claude -p), Claude Code 2.1.316, trimmed
$ claude -p --continue "Which session is this, and what was my last question? One sentence." --permission-mode plan

This is the orders-service session on the `session-tour` branch (transcript `5e3d7348-9c70-46a8-a7e9-093c77fd1618`), and your last question before this one asked me, without editing anything, to say in two sentences what we did and what state `OrderService` is in after you reverted my tidy-up with git.

It reported the same session ID as before. In our run, resuming did not create a new session.

Finish with a precise request​

Now the right way to ask. One file, one test, one check. This closes the gap we left in Part 2, where only a quantity of 101 was tested:

Type into Claude Code

Add one test to OrderControllerTest, next to the 101 test: a quantity of exactly 100 is accepted and returns 201. Do not change any other file. Then run ./mvnw test and tell me the result in two sentences.

One precise test, and the test runNon-interactive run (claude -p), Claude Code 2.1.316, trimmed
$ claude -p "Add one test to OrderControllerTest, next to the 101 test: ..." --resume orders-tour --permission-mode acceptEdits --allowedTools "Bash(./mvnw test*)"

I added `postAcceptsAQuantityOfExactlyOneHundred` to `OrderControllerTest.java`, right after the 101 test. It posts a quantity of 100 and expects a 201 Created, and I changed no other file. `./mvnw test` finished with BUILD SUCCESS: 10 tests ran (7 in `OrderControllerTest`, 3 in `OrderServiceTest`) with no failures, errors or skips.
diff --git a/src/test/java/com/agentworks/orders/OrderControllerTest.java b/src/test/java/com/agentworks/orders/OrderControllerTest.java
index 711c2b9..5d75bb6 100644
--- a/src/test/java/com/agentworks/orders/OrderControllerTest.java
+++ b/src/test/java/com/agentworks/orders/OrderControllerTest.java
@@ -52,6 +52,16 @@ class OrderControllerTest {
.andExpect(jsonPath("$.title").value("Invalid order"));
}

+ @Test
+ void postAcceptsAQuantityOfExactlyOneHundred() throws Exception {
+ mvc.perform(post("/orders").contentType(MediaType.APPLICATION_JSON)
+ .content("""
+ {"customerEmail": "ana@example.com",
+ "items": [{"productName": "Keyboard", "quantity": 100, "unitPrice": 20.00}]}
+ """))
+ .andExpect(status().isCreated());
+ }
+
@Test
void getListsOrders() throws Exception {
mvc.perform(post("/orders").contentType(MediaType.APPLICATION_JSON).content(ONE_ITEM))

Compare this prompt with "Tidy up OrderService". It names the file, the case, the expected status, and the limit: no other file. The diff is 10 lines, and every line is what we asked for.

Run the tests yourself:

./mvnw test
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 19.02 s -- in com.agentworks.orders.OrderControllerTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.415 s -- in com.agentworks.orders.OrderServiceTest
[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
[INFO] Total time: 30.214 s

Ten tests, one more than before, and BUILD SUCCESS. The folder part-03/finished holds this result.

Keep the context in check​

A long session fills the context window. Figure 3 shows the life of a session, with the one place where you decide to trim.

The life of a sessionFive steps from left to right. 1 Start: claude with a name, or --continue. 2 Work: prompts, edits and the undo ladder. 3 Trim: when the context fills, run /compact to summarize or /clear to start fresh; you decide. 4 Leave: press Ctrl+D twice or run /exit. 5 Resume: claude --resume with the name, or /resume inside a session. Two go-back arrows: from step 3 back to step 2 to keep working, and from step 5 back to step 2 with the same conversation and history.Startclaude -n nameor --continue1Workprompts, edits,the undo ladder2Trim/compact or /clearwhen context fills3YOU DECIDELeaveCtrl+D twice,or /exit4Resumeclaude --resume nameor /resume5keep workingsame conversation, same historyThe life of a sessionFive steps from top to bottom. 1 Start: claude with a name, or --continue. 2 Work: prompts, edits and the undo ladder. 3 Trim: when the context fills, run /compact or /clear; you decide. 4 Leave: Ctrl+D twice or /exit. 5 Resume: claude --resume with the name, or /resume. A dashed arrow goes back from step 5 to step 2, with the same conversation and history. From step 3 you can also go straight back to step 2.Startclaude -n name or --continue1Workprompts, edits, the undo ladder2Trim/compact or /clear when context fills3YOU DECIDELeaveCtrl+D twice, or /exit4Resumeclaude --resume name or /resume5The dashed arrow goes back from step 5 to step 2:same conversation, same history. From step 3you can also go straight back to step 2.
Figure 3: The life of a session. The orange box is where you decide to trim. The dashed arrows go back.

/context shows what is using the window. This is real output from our scratch project, trimmed to the summary table. We cut the list of installed skills, which is specific to our machine:

/context, trimmedNon-interactive run (claude -p), Claude Code 2.1.316, trimmed, 19 lines. Select to show.
$ claude -p "/context"

## Context Usage

**Tokens:** 18.3k / 1m (2%)

### Estimated usage by category

| Category | Tokens | Percentage |
|----------|--------|------------|
| System prompt | 2.5k | 0.2% |
| System tools | 7.5k | 0.8% |
| System tools (deferred) | 15.8k | 1.6% |
| Skills | 8.3k | 0.8% |
| Messages | 10 | 0.0% |
| Free space | 948.7k | 94.9% |
| Autocompact buffer | 33k | 3.3% |

...

On a fresh session, 2 percent of the window was used. Most of that is fixed: the system prompt, tools and skills. A long session grows the Messages row.

When it fills, you have two choices. From the commands page, read on 31 October 2026:

  • /compact [instructions] frees context by summarizing the conversation so far. You can pass focus instructions. The context window page gives an example: /compact focus on the auth bug fix.
  • /clear starts a new conversation with empty context. The previous one stays available in the /resume picker.

Rule of thumb from the docs: /clear when you switch to unrelated work, /compact when you continue the same work. Claude Code also compacts by itself near the limit.

Two more commands belong in your daily set. /usage shows session cost and plan limits, with /cost and /stats as aliases. We did not print ours, because the screen lists other projects on our machine. /rename renames the session.

We tried /compact in a -p run, and it printed nothing. We could not confirm that it ran, so we do not claim a result.

Run commands and background tasks​

Start a line with ! and Claude Code runs it as a shell command. Per the docs, the command and its output join the conversation, and Claude responds to the output. That makes ! ./mvnw test a quick way to run the tests and let Claude read the failure. Leave shell mode with Esc, Backspace or Ctrl+U on an empty prompt.

One safety note from the same page: commands you type in shell mode run outside the sandbox, even if you turned sandboxing on. Part 5 covers the sandbox.

For a long command, press Ctrl+B while it runs. It moves to the background, and the output goes to a file Claude can read. /tasks shows running shells and subagents. The docs say background tasks are cleaned up when Claude Code exits.

Switch model or effort​

Pick the model and effort for the job. From the model configuration page, read on 31 October 2026:

  • At startup: claude --model <alias> and claude --effort <level>.
  • In a session: /model <alias>, or /model with no argument for a picker. /effort <level> sets the effort.
  • A key: Alt+P opens the model switch without clearing your prompt.

The picker saves your choice as the default for new sessions, unless you press s to switch for this session only. The --model flag and the ANTHROPIC_MODEL setting apply only to the session you launch with them.

The effort levels are low, medium, high, xhigh and max, plus auto. We checked ours in a real run:

/effort statusNon-interactive run (claude -p), Claude Code 2.1.316, trimmed
$ claude -p "/effort status"

Effort level: auto (currently medium)

Both flags work in -p, too. We asked a trivial question with the haiku alias and --effort low, and got the one word we asked for:

claude -p "Reply with the single word: ready" --model haiku --effort low
ready

Our rule: low effort and a smaller model for simple questions and searches, the default for edits, and more effort for hard bugs. We did not measure the savings, so we give no numbers.

What went wrong​

Git Bash rewrote our slash command. Our first attempts to run /context and /usage in a -p call did not work. Git Bash on Windows turns a leading / in an argument into a Windows path. Claude Code received the path instead of the command:

The slash command that Git Bash rewroteNon-interactive run (claude -p), Claude Code 2.1.316, trimmed
$ claude -p "/context"   # in Git Bash, before the fix

`C:/Program Files/Git/context` looks like a mangled `/context` command. Git Bash rewrote the leading `/` into its install path, so I didn't get what you meant to send.
...

It explained the cause, which is useful. The fix is to turn off the path conversion for the shell, or to use PowerShell:

export MSYS_NO_PATHCONV=1

With that set, /effort status, /context and /usage worked. In an interactive session you type commands into Claude Code, not into Bash, so this only bites in scripts and one-off -p calls.

A vague prompt cost us an edit. "Tidy up OrderService" is what you type when you are in a hurry. It returned a refactor that we did not want, and the tests were not run. The undo ladder worked, but prevention is cheaper. Say what to change, and what not to touch.

/compact printed nothing. We do not know why, and we did not dig. It may be that the command does not report anything in -p, or that it did not run. Check in an interactive session before you rely on it in a script.

Stay in control​

The safety habit for this part: know your rung before you need it.

  1. Commit before a big prompt. Rung 4 depends on it.
  2. Keep prompts narrow, so the diff is small enough to read in one go.
  3. Read the diff after every edit, even when the summary says all is well.
  4. Remember what rewind does not cover: files that only a Bash command changed.

Cheat sheet​

Command, key or promptWhat it does
claude -n <name>Starts a session with a name.
claude --continueReopens the most recent session in this directory.
claude --resume <name>Resumes a named session.
/resumeSwitches to another session.
/rename <name>Names the current session.
EscStops the response. Declines a permission prompt.
Esc twice on an empty prompt, or /rewindOpens the rewind menu.
Ctrl+CInterrupts, or clears the input, then exits.
Shift+TabCycles the permission mode.
! at the start of a lineRuns a shell command and adds its output.
Ctrl+RSearches your command history.
Ctrl+B, /tasksBackgrounds a running command. Lists background work.
/contextShows what fills the context window.
/compact [focus]Summarizes the conversation to free context.
/clearStarts a new conversation with empty context.
/usageShows session cost and plan usage.
/model, Alt+P, /effortSwitch model or effort.
git restore <file>The last rung: back to your last commit.
Add one test to X ... Do not change any other file. Run ./mvnw test.A narrow prompt with a limit and a check.

Try it yourself​

Three exercises on the same project. Start each from a clean branch.

  1. Practice the undo ladder. Ask for a vague change, such as "Improve OrderController". When it edits, press Esc to stop, then Esc twice to open the rewind menu and choose Restore code. Hint: do this in an interactive session. A good result is git status showing nothing, and the conversation still open. Then try the same with a change that came from a ! command, and see that rewind does not undo a file only the shell changed.
  2. Name, leave and resume. Start claude -n my-tour, ask one question, press Ctrl+D twice, then run claude --resume my-tour. Hint: ask "what did I last ask you?" A good result is an answer that names your question. Then open /resume and find the session in the picker.
  3. Watch the context. Run /context, read three files with @, and run /context again. Hint: compare the Messages row. A good result is a larger Messages number. Then run /compact with a focus sentence, run /context once more, and compare.

What comes next​

Part 4, "CLAUDE.md for a Spring Boot project", is not published yet. It teaches Claude Code your build and test commands once, so you stop repeating them in every prompt.

You can go back to Part 1 at any time. To follow along, subscribe to the RSS feed, or follow @agentworkshq on X or @agentworkshq on Instagram. The series page has the current list.

Share this article

Sponsored by DVARA. Runtime AI governance for LLM, MCP and agent calls: policy enforcement, data protection, prompt-injection defence, spend controls and tamper-evident audit logs.

dvarahq.com →