Tutorial11 min read

Advanced Best Practices - Tutorial

SFEIR Institute•

TL;DR

This tutorial guides you through the advanced practices of Claude Code to optimize your professional workflows, debug effectively, and collaborate as a team on existing projects. You will learn how to configure reproducible work patterns, diagnose complex bugs, and integrate Claude Code into a collaborative CI/CD pipeline.

This tutorial guides you through the advanced practices of Claude Code to optimize your professional workflows, debug effectively, and collaborate as a team on existing projects. You will learn how to configure reproducible work patterns, diagnose complex bugs, and integrate Claude Code into a collaborative CI/CD pipeline.

Advanced best practices for Claude Code are a set of techniques and patterns that allow experienced developers to fully leverage the tool's potential in a professional context. Claude Code (version 2.1.x or later) has seen rapid adoption as a development assistant in terminal environments.

SFEIR Institute trainings

Claude Code Training

1 day · Fundamentals

View program

AI-Augmented Developer

2 days · Intermediate

View program

What are the prerequisites before getting started?

Before following this step-by-step tutorial, verify that your environment meets the following requirements. These prerequisites ensure a smooth experience throughout all the steps.

PrerequisiteMinimum versionVerification
Node.js18 or laternode --version
Claude Code CLI2.xclaude --version
Git2.40+git --version
CLAUDE.md fileConfiguredcat CLAUDE.md

Install Node.js 18 or later if not already done (only the npm install path requires Node; the native binary needs no Node at all). In practice, many startup errors come from an outdated Node.js version.

node --version
claude --version
git --version

If you have not yet configured your environment, check the installation and first launch tutorial which covers each step of the initial setup.

Total estimated duration: approximately 45 minutes for the entire track.

Key takeaway: all prerequisites must be validated before moving to step 1 to avoid blockers along the way.

How to configure a reproducible professional workflow? (Step 1 - ~5 min)

Create a CLAUDE.md file at the root of your project with explicit team conventions.

# Project conventions

## Code style
- TypeScript strict, no `any`
- Unit tests mandatory for each exported function
- Conventional commits (feat:, fix:, chore:)

## Architecture
- Clean Architecture: domain/ -> application/ -> infrastructure/
- No circular imports between layers

This first step takes less than 2 minutes. Claude Code reads this file at each session and adapts its responses to your conventions.

A well-maintained CLAUDE.md file reduces repeated corrections on generated suggestions. The time invested in this file pays off across every subsequent code review.

To go further on memory configuration, the CLAUDE.md memory system guide details advanced customization options.

Verification:

cat CLAUDE.md
# You should see your conventions displayed

If you see No such file or directory, create the file with touch CLAUDE.md then edit it.

Key takeaway: the CLAUDE.md file is the pillar of every reproducible professional workflow with Claude Code.

How to structure effective multi-step prompts? (Step 2 - ~5 min)

Use the /init slash command to generate a basic CLAUDE.md, then enrich it with workflow instructions. Start a Claude Code session first, then run the slash command from inside it.

claude

Then, at the prompt, run: /init

Split your complex requests into explicit sub-tasks. Here is how to formulate a performant multi-step prompt:

1. Read the file src/auth/login.ts
2. Identify input validation flaws
3. Propose a fix with unit tests
4. Verify that existing tests still pass

In practice, a prompt structured in numbered steps tends to produce more accurate results than a monolithic prompt. Claude Code processes each step sequentially and preserves context between them.

You can also combine this approach with the essential slash commands to accelerate each sub-task.

Verification: launch a multi-step request and observe that Claude Code numbers its responses mirroring your structure.

Key takeaway: structuring your prompts in numbered steps improves the accuracy and predictability of Claude Code's output.

How to debug effectively with Claude Code? (Step 3 - ~8 min)

Launch Claude Code in the buggy project directory and provide it with the exact error message.

cd my-project && claude

Debugging with Claude Code relies on three phases: reproduction, diagnosis, correction. Paste the full stacktrace in your prompt for optimal diagnosis.

Here is the error I get:
TypeError: Cannot read properties of undefined (reading 'map')
 at UserList (src/components/UserList.tsx:42:18)
Analyze this stacktrace and propose a fix.

Claude Code analyzes the source file, identifies the faulty line, and proposes a patch. In practice, many common bugs are resolved quickly with this method.

How to use iterative mode for complex bugs?

For stubborn bugs, activate an iterative diagnostic loop:

claude "Run the tests, analyze the failures, fix the code, then rerun the tests until everything passes"

This iterative approach is detailed in the advanced debugging guide which covers the most common scenarios.

If you see Context window limit reached, reduce the size of the pasted stacktrace or use /clear to reset the context. Check the context management tutorial to master this limit.

Verification:

npm test
# All tests should pass after correction

Key takeaway: always paste the full stacktrace and use iterative mode for stubborn bugs.

How to work with existing projects and legacy code? (Step 4 - ~8 min)

Open Claude Code at the root of a legacy project and ask it for a structural analysis before any modification.

claude "Analyze the structure of this project. List obsolete dependencies, anti-patterns, and the most modified files according to git log"

Claude Code browses the file tree, reads configuration files (package.json, tsconfig.json) and cross-references these data with Git history. This initial analysis may take some time depending on the size of the project.

How to refactor legacy code safely?

Apply the "safety net" rule: never refactor without existing or pre-generated tests.

1. Generate tests for src/legacy/paymentProcessor.js
 covering the edge cases visible in the code
2. Refactor the file into strict TypeScript
3. Verify that all tests pass after refactoring

many consider legacy code modernization as their most time-consuming task. Claude Code helps reduce this time by generating test coverage automatically.

In practice, Claude Code can generate a suite of unit tests for a source file in a single pass. You can then adjust these tests manually before launching the refactoring.

To manage permissions during sensitive modifications on legacy code, the permissions and security tutorial shows you how to configure appropriate safeguards.

Verification:

npx jest --coverage src/legacy/
# Target coverage: > 80%

If you see tests failing before even starting the refactoring, fix the existing tests first. Never refactor code whose tests are already red.

Key takeaway: always generate tests BEFORE refactoring legacy code. This is your essential safety net.

How to work as a team with Claude Code? (Step 5 - ~8 min)

Share the CLAUDE.md file via Git so the entire team benefits from the same conventions. The CLAUDE.md file is the collaboration contract between developers and AI.

git add CLAUDE.md
git commit -m "chore: add team conventions for Claude Code"
git push origin main

How to standardize practices within the team?

Define three levels of CLAUDE.md in your project:

LevelFileScopeExample
Global~/.claude/CLAUDE.mdAll sessionsPersonal preferences
Project./CLAUDE.mdEntire projectTeam conventions
Subfolder./src/api/CLAUDE.mdSpecific moduleREST API rules

In practice, teams using a shared CLAUDE.md see significant in code review comments related to style. Each team developer gets suggestions consistent with the project standards.

You can combine this approach with the advanced best practices to maximize collective efficiency.

How to integrate Claude Code into a CI/CD pipeline?

Add Claude Code as a verification step in your GitHub Actions pipeline:

#.github/workflows/claude-review.yml
name: Claude Code Review
on: [pull_request]
jobs:
 review:
 runs-on: ubuntu-latest
 steps:
 - uses: actions/checkout@v4
 - name: Claude Code Review
 env:
 CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
 run: |
 claude -p "Analyze this diff and flag potential issues: $(git diff origin/main...HEAD)"

teams that integrate Claude Code into their CI/CD can catch more issues before production deployment, with only a modest impact on pipeline duration.

SFEIR Institute offers the AI-Augmented Developer training over 2 days which includes hands-on labs on integrating Claude Code into team workflows and CI/CD pipelines. You will learn how to configure these automations in real-world conditions.

Verification:

gh workflow view claude-review.yml
# The workflow should appear as active

Key takeaway: the CLAUDE.md file shared via Git is the pillar of team collaboration with Claude Code.

How to manage common errors in an advanced context? (Step 6 - ~5 min)

Identify recurring errors and configure automated responses. Here are the 5 most frequent errors encountered by advanced users.

ErrorCauseSolution
Context window exceededToo many files loaded/clear + rephrase
Permission deniedRestrictive mode activeclaude --allowedTools "Read" "Edit" "Bash" (or /permissions in-session)
Rate limit reachedToo many requests/minWait and retry
File not foundIncorrect relative pathUse absolute path
Timeout on large fileVery large fileSplit the file or read it in sections

Configure your permissions file to avoid repeated blockers:

{
 "permissions": {
 "allow": ["Read", "Write", "Edit", "Bash"],
 "deny": ["Read(./.env)", "Read(./.env.*)", "Read(./secrets/**)"]
 }
}

You will encounter the term "context window" when Claude Code refuses to process your request. The context window is the maximum amount of text the model can process in a single session, a large window for the current Claude models.

For in-depth troubleshooting, the troubleshooting guide and the common mistakes list cover each case in detail.

If you see Rate limit reached repeatedly, reduce the frequency of your calls or upgrade to a plan with a higher quota.

Verification: run claude "test". You should get a response in less than 5 seconds without error.

Key takeaway: anticipating common errors saves meaningful time during a development session.

How to evaluate your mastery of Track A? (Step 7 - ~6 min)

Complete this final assessment to measure your progression across the entire Track A. Each exercise validates a key skill.

Exercise 1: Reproducible workflow

Create a complete CLAUDE.md for a fictitious project and verify that Claude Code respects your conventions:

claude "Generate a TypeScript function that validates an email. Follow the CLAUDE.md conventions."

Verify that the generated code uses strict TypeScript, includes a unit test, and follows the conventional commit format.

Exercise 2: Iterative debugging

Intentionally inject a bug into a test file and ask Claude Code to find it:

claude "There is a bug in src/utils/validator.ts. Tests are failing. Find and fix the problem."

In practice, this exercise takes between 2 and 4 minutes depending on the complexity of the injected bug.

Exercise 3: Legacy refactoring

Select a JavaScript file from your project and request a complete TypeScript conversion with tests.

To solidify these skills, the Claude Code training in 1 day lets you practice these patterns in real-world conditions with guided exercises. If you want to go even further, the AI-Augmented Developer - Advanced training covers in 1 day advanced optimization techniques and complex prompt architectures.

Evaluated skillSuccess criterionPoints
CLAUDE.md workflowConventions respected in generated code/25
DebuggingBug found and fixed in < 3 min/25
Legacy refactoringTests generated + TS conversion successful/25
Team collaborationShared CLAUDE.md + CI/CD configured/25

Verification: a score of 75/100 or more validates your mastery of Track A.

You can also revisit the first conversations with Claude Code to consolidate fundamentals if some points remain unclear.

Key takeaway: the final assessment covers four pillars (workflow, debugging, legacy, and collaboration) that form the foundation of the AI-augmented developer.

How to go further after this tutorial?

Explore complementary resources to deepen each skill. The journey does not stop at this assessment: advanced techniques evolve with each Claude Code update.

Here is how to continue your skill development:

  1. Deepen the memory system with the advanced CLAUDE.md tutorial
  2. Master context management through the dedicated guide
  3. Practice advanced debugging with the debugging guide
  4. Automate your workflows with slash commands

SFEIR has been supporting development teams in AI tool adoption since 2024. SFEIR Institute delivers Claude Code and AI-Augmented Developer training programs to development teams.

a growing share of developers now use an AI assistant daily. By training now, you are taking a head start on this transformation.

Key takeaway: mastering Claude Code is a continuous investment. Each new version brings features that enrich your workflow.

Recent articles about Claude

Recommended training

Claude Code Training

Master Claude Code fundamentals in 1 day with our expert instructors. 60% hands-on practice on real-world cases.

Discover the training