Tutorials

Step-by-step guides for common ContextVault workflows.

Tutorial 1: Setting Up Your First Project

Learn how to initialize ContextVault in a new project and create your first documents.

Step 1: Install ContextVault

If you haven't already, install ContextVault:

# macOS/Linux
curl -sL https://ctx-vault.com/install | bash

# Windows PowerShell
irm https://ctx-vault.com/install.ps1 | iex

Step 2: Navigate to Your Project

cd /path/to/your/project

Step 3: Initialize the Vault

In Claude Code, type:

/ctx-init

This creates:

Step 4: Bootstrap Documentation (Optional)

For existing codebases, auto-generate documentation:

/ctx-bootstrap

This scans your codebase and creates:

Step 5: Check Your Status

/ctx-status

You should see your newly created documents listed.

Success!

Your project is now set up with ContextVault. Every new Claude Code session will automatically read your vault and have full context.

Tutorial 2: Documenting Bug Fixes

Learn the best practice for documenting bugs and their solutions.

When to Document

Step 1: Fix the Bug

Work through your debugging process as normal.

Step 2: Document with /ctx-error

Once fixed, immediately document:

/ctx-error

Step 3: Provide Details

Claude will ask for:

Example Document Created

# P005 - TypeError in User Authentication

> **Status:** Active
> **Created:** 2026-01-20

## Error
TypeError: Cannot read property 'id' of undefined
at AuthService.validateToken (auth.ts:45)

## Root Cause
The JWT payload structure changed after upgrading jsonwebtoken.
Old: { userId: '123' }
New: { sub: '123' }

## Solution
Updated AuthService to use `payload.sub` instead of `payload.userId`.

## Prevention
- Pin jsonwebtoken version in package.json
- Add unit test for token payload structure
Why Document Bugs?

Next time a similar error occurs, Claude can search your vault and instantly recall the solution. No more re-debugging the same issues!

Tutorial 3: Creating Effective Session Handoffs

Learn how to end sessions so the next one can seamlessly continue.

When to Create Handoffs

Step 1: Before Ending Your Session

/ctx-handoff

Step 2: Claude Generates the Summary

The handoff document includes:

Example Handoff Document

# P008 - Session Handoff 2026-01-20

## Completed
- Implemented user registration API endpoint
- Added input validation with Zod
- Created database migration for users table

## In Progress
- Email verification flow (50% done)
  - Created email template
  - Still need: verification endpoint, token storage

## Blocked
- Waiting for SMTP credentials from DevOps

## Next Steps
1. Finish email verification endpoint
2. Add password reset flow
3. Write integration tests

## Context
- Using Resend for email (not SendGrid)
- Token expiry set to 24 hours per product decision

Step 3: Next Session Automatically Loads Context

When you start a new session, Claude reads the index and knows exactly where you left off.

Tutorial 4: Building a Global Pattern Library

Learn how to capture reusable patterns that help across all projects.

What Makes a Good Global Pattern?

Examples of Global Patterns

PatternDescription
Docker multi-stage buildsOptimized Dockerfile pattern
Git branch strategyYour preferred workflow
Error handling middlewareExpress/Fastify error pattern
Database connection poolingPostgreSQL pool config

Step 1: Identify a Reusable Pattern

When you solve a problem that could help in other projects.

Step 2: Document with /ctx-snippet

/ctx-snippet

Snippets default to global vault for reuse.

Step 3: Provide Pattern Details

Example Global Pattern

# G003 - Express Error Handler Pattern

## Use Case
Centralized error handling for Express APIs.

## Pattern
```javascript
const errorHandler = (err, req, res, next) => {
  const status = err.status || 500;
  const message = err.message || 'Internal Server Error';

  // Log for debugging
  console.error(`[${status}] ${message}`, err.stack);

  // Send response
  res.status(status).json({
    error: { message, code: err.code }
  });
};

// Use after all routes
app.use(errorHandler);
```

## Notes
- Always define after routes
- Extend for specific error types (ValidationError, etc.)
- Consider adding request ID for tracing

Tutorial 5: Team Workflow with Git

Share project documentation across your team by committing the vault.

Step 1: Add Vault to Git

# The .claude/vault directory is already git-friendly
git add .claude/vault/
git commit -m "Add project documentation vault"

Step 2: Team Members Pull the Vault

When team members clone or pull, they get all project docs:

git pull origin main
# Now everyone has .claude/vault/

Step 3: Individual Contributions

Each team member's Claude sessions can read and update the shared vault:

What to Keep Private

The global vault (~/.claude/vault/) is personal and never shared. It contains your individual patterns and preferences.

Git Best Practice

Treat vault commits like code commits. Include doc updates in the same PR as related code changes.