# Claude Code tips: 10 habits that get better results

> Ten practical Claude Code habits: explore before editing, give it a way to verify, keep context clean, use permission modes and hooks, and write a short CLAUDE.md.

Source: https://devaiper.com/blog/claude-code-tips
Published: 2026-10-08
Topics: Claude Code, Productivity, Tutorial

**Short answer:** Claude Code gets better when you give it a goal, a way to check its own work, and a small clean context. Explore first, specify precisely, verify with tests, clear between tasks, and put repeated rules in CLAUDE.md.

Most "Claude Code is bad at this" complaints come from the same few causes: a vague goal, no way to check the result, and a context window full of old junk. These ten habits fix most of them. If you have not used it yet, start with [what Claude Code is](https://devaiper.com/blog/what-is-claude-code).

## 1. Say the outcome, not the activity

"Fix the bug" forces a guess. "Fix the login bug where users see a blank screen after entering wrong credentials" does not. Include the symptom, where you see it, and what done looks like.

## 2. Let it explore before it edits

Ask for understanding first: `analyze the database schema`, `how does auth work in this repo?`. The agent builds a map, and you catch wrong assumptions before they become code.

## 3. Give it a way to check its own work

This is the biggest lever. Name the command: "run `pnpm test auth` and fix failures", "run the type check after each file". An agent that can read a failing test fixes things in a loop. One that cannot will confidently stop.

> **Diagram:** Comparison of two prompts. Without a check the agent writes code and stops, and you find the bug later. With a check command the agent runs the test, reads the failure and fixes it before handing back.
> No check: Writes the code; Says it is done; You find the bug in review. With a check: Writes the code; Runs the test, reads the failure; Fixes it, runs again, then hands back.

## 4. Break big work into steps

```text
1. create a table for user profiles
2. add an API endpoint to get and update a profile
3. build a page that shows and edits it
```

Small steps are reviewable. A 40-file diff is not.

## 5. Keep the context clean

Context is the agent's working memory, and it is finite. Run `/clear` between unrelated tasks. If a session has gone sideways after three corrections, start fresh with a better first prompt instead of arguing. `claude -c` continues the last conversation and `claude -r` lets you pick one.

## 6. Write the repeated stuff down once

Same correction twice? It belongs in [CLAUDE.md](https://devaiper.com/blog/claude-md-guide): build commands, conventions, no-go folders. Keep it short and checkable.

## 7. Choose the permission mode on purpose

`Shift+Tab` cycles the mode. Use the strict default for unfamiliar code, loosen it for well-tested changes. Always read the diff before committing.

## 8. Use hooks for must-never rules

"Never edit `generated/`" in CLAUDE.md is a request. A PreToolUse hook is a rule. If breaking it is expensive, enforce it.

## 9. Use it from scripts

```bash
claude -p "list every TODO in src/ grouped by file"
```

`-p` runs one prompt and exits, so you can pipe results or call it in CI.

## 10. Review like it is a junior's pull request

Run the tests yourself, read the diff, question anything surprising. Your name is on the commit. This is the **Diligence** part of the [4D framework](https://devaiper.com/blog/4d-framework-ai-fluency), and it is what separates [AI-assisted engineering from vibe coding](https://devaiper.com/blog/vibe-coding-vs-ai-assisted-engineering).

## Quick recap

| Habit | Why it works |
|---|---|
| Specific outcome | Removes guessing |
| Explore first | Catches wrong assumptions early |
| Verification command | Lets the agent self-correct |
| Small steps | Reviewable diffs |
| `/clear` | Fresh, relevant context |
| CLAUDE.md | Stops repeated mistakes |
| Hooks | Enforcement, not hope |

## FAQ

### How do I get better results from Claude Code?

Be specific about the outcome, let it explore the code before changing it, give it a test or command it can run to verify its work, keep tasks small, and record repeated instructions in CLAUDE.md.

### When should I use /clear in Claude Code?

Between unrelated tasks. A long conversation fills the context window with stale detail, and starting fresh with a clear prompt usually works better than correcting a confused session.

### Can I run Claude Code in scripts or CI?

Yes. claude -p "query" runs a single prompt non-interactively and prints the result, which is what you use in scripts.

### How do I stop Claude Code from doing something dangerous?

Use permission modes for day-to-day control and a PreToolUse hook for anything that must be blocked every time. Instructions in CLAUDE.md are context, not enforcement.

