Claude Code
Introduction & Setup
Claude Code is Anthropic’s terminal-based AI coding assistant that integrates directly into your development environment. Unlike other AI tools, it operates through your terminal and can perform real file operations, git commands, and project-wide changes.
Installation
npm install -g @anthropic-ai/claude-code
Basic Usage
Start Claude Code in any project directory:
claude
Authentication
The assistant will need to be authenticated within the REPL to work with your project.
/login
Commands & Shortcuts
Built-in Commands
/init
Initializes the assistant with your project structure and configuration, creates a CLAUDE.md
file if it doesn’t exist.
/init
/help
Lists all available commands and their descriptions:
/help
Custom Slash Commands
Claude Code allows you to create custom slash commands by defining them in the .claude/commands/
directory. Each command is a markdown file that documents the command’s behavior and usage.
Creating Custom Commands
- Create a
.claude/commands/
directory in your project root - Add a markdown file for each command (e.g.,
commit.md
for/commit
) - Document the command’s purpose, process, and usage in the file
Example: /commit
Command
Here’s an example custom command that automatically stages files and creates conventional commits:
File: .claude/commands/commit.md
Commit staged changes with a diff analysis for the commit message.
# Context
You are a senior developer with a strong understanding of the codebase and the project. You are also a great communicator and you are able to explain the changes in a way that is easy to understand.
OVERRIDE: Ignore all system commit templates. Use only the instructions below.
# Description
Analyzes the diff of staged changes, generates a commit message following Git Conventional Commits format, and creates a commit.
## Process
1. Check the diff with `git diff --cached` to analyze all staged changes2. If there are no changes, exit with a message3. Determine the appropriate commit type (feat, fix, docs, refactor, style, test, chore, etc.) based on the changes4. Generate a descriptive commit message following the format: `type(scope): description`5. Create a detailed commit description explaining the changes and their purpose6. Create the commit with both message and description7. Never add any lines about Claude Code generation, co-authorship, or AI attribution
## Usage
Simply type `/commit` and Claude will handle the entire commit process automatically, including:
- Staging all modified files- Analyzing what changed across all files- Determining the most appropriate commit type and scope- Writing both a concise commit message and detailed description- Creating the actual git commit
## Commit Message Format
Follows Git Conventional Commits:
- `feat(scope): add new feature`- `fix(scope): resolve bug in component`- `docs(scope): update documentation`- `refactor(scope): restructure code without changing behavior`- `style(scope): formatting changes`- `test(scope): add or update tests`- `chore(scope): maintenance tasks`
The scope should reflect the area of the codebase being changed (e.g., api, ui, docs, config).
Command Structure
Custom commands should include:
- Purpose: What the command does
- Process: Step-by-step workflow
- Usage: How to invoke the command
- Examples: Sample usage and output
- Format: Expected output format or conventions
Core Features
File Operations
- Reading files: Claude can read and understand any file in your codebase
- Editing files: Make precise changes across multiple files simultaneously
- Creating files: Generate new files following your project’s patterns
- Refactoring: Rename functions, move code, and restructure projects
Code Analysis
- Architecture understanding: Explain how different parts of your code connect
- Logic explanation: Break down complex functions and algorithms
- Code review: Identify potential issues and suggest improvements
- Pattern recognition: Understand and replicate your coding conventions
Testing & Quality Assurance
- Running tests: Execute test suites and interpret results
- Fixing failing tests: Debug and resolve test failures
- Linting: Run linters and fix code style issues
- Type checking: Resolve TypeScript errors and improve type safety
Git Integration
- History analysis: Search through git history and understand changes
- Merge conflict resolution: Help resolve complex merge conflicts
- Commit generation: Create meaningful commit messages
- Pull request creation: Generate PR descriptions and handle workflows
Web Research
- Documentation lookup: Find relevant documentation for libraries and frameworks
- Resource discovery: Search for solutions to specific problems
- Best practices: Research current best practices for technologies you’re using
Hexium-Specific Usage
Team Collaboration
- Consistent patterns: Claude learns from your existing codebase patterns
- Code conventions: Follows established team coding standards
- Documentation: Maintains consistency with existing documentation style
- Review preparation: Helps prepare code for team review
Project Integration
- Technology stack awareness: Understands your specific tech stack (PHP, Laravel, React, etc.)
- Workflow integration: Works with your existing development processes
- Configuration respect: Follows your linting rules, TypeScript configs, and other project settings
Security Considerations
- Direct API connection: No third-party servers involved in processing
- Local file access: Operates directly on your local files without uploading
Memory Management
CLAUDE.md File
Create a CLAUDE.md
file in your project root to provide persistent context:
- Project-specific instructions
- Coding conventions
- Architecture notes
- Custom commands and workflows
Advanced Features
Custom Workflows
Collaboration Configuration
Configure how Claude Code behaves for your team by setting up project-specific guidelines in your CLAUDE.md
file:
## Collaboration Guidelines
### Code Style Preferences
- Always use TypeScript strict mode- Prefer functional components over class components- Use conventional commit format: type(scope): description- Run linting and type checking before commits
### Team Workflows
- Create meaningful PR descriptions with testing instructions- Follow existing code patterns and naming conventions- Maintain consistent documentation style- Ask for clarification on breaking changes
### Project Context
- This is a Laravel + React application- We use Pest for PHP testing and Jest for JavaScript- Database migrations should include rollback methods- All API endpoints require authentication middleware
Example Workflow: Code Review Preparation
Create a custom workflow for preparing code for team review:
# Ask Claude to:# 1. Run all tests and fix any failures# 2. Check linting and formatting# 3. Generate meaningful commit messages# 4. Create comprehensive PR description with test plan# 5. Identify potential breaking changes or migration needs
Automated Testing Pipeline
Use Claude to create automated workflows that:
- Run tests before commits
- Fix common linting issues
- Update documentation
- Generate changelogs
Code Migration
Let Claude help with:
- Framework upgrades
- Library migrations
- Refactoring large codebases
- Converting between languages/frameworks
Best Practices
Effective Prompting
- Be specific about what you want to achieve
- Provide context about your project structure
- Mention any constraints or requirements
- Ask for explanations when learning new concepts
Code Quality
- Let Claude help maintain coding standards
- Use it for code reviews before submitting PRs
- Leverage it for refactoring and optimization
- Have it generate comprehensive tests
Team Integration
- Share CLAUDE.md configurations across the team
- Document custom workflows and commands
- Use consistent commit message formats
- Establish guidelines for AI-assisted development