Skip to content

Instantly share code, notes, and snippets.

@deva-u7
Created March 20, 2026 12:08
Show Gist options
  • Select an option

  • Save deva-u7/a213d9895adb47de7c854294df6f749d to your computer and use it in GitHub Desktop.

Select an option

Save deva-u7/a213d9895adb47de7c854294df6f749d to your computer and use it in GitHub Desktop.
Claude Code — CLI Setup, MCP & Daily Usage Guide

Claude Code — Setup & Reference

Install

npm install -g @anthropic-ai/claude-code
claude --version

Requires Node.js 18+.


Run

claude                          # interactive session
claude "your prompt" --print    # one-shot, print and exit
Flag Purpose
--model claude-opus-4-6 Override model
--print Non-interactive output
--no-stream Disable streaming

GitHub MCP Setup

Step 1 — Create a Fine-Grained PAT

GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens

Permission Level
Contents Read and Write
Issues Read and Write
Pull requests Read and Write
Metadata Read (auto)

Step 2 — Add MCP Servers

Run once in terminal. Replace YOUR_TOKEN with your PAT.

claude mcp add github -s user -e GITHUB_PERSONAL_ACCESS_TOKEN=YOUR_TOKEN -- npx -y @modelcontextprotocol/server-github
claude mcp add filesystem -s user -- npx -y @modelcontextprotocol/server-filesystem /your/work/directory
claude mcp add fetch -s user -- npx -y @modelcontextprotocol/server-fetch

Restart Claude Code after adding servers.

Step 3 — Verify

/mcp

Lists all connected servers and tools. Ask Claude "list my GitHub repos" to confirm it's working.


Quick Reference

Slash Commands

Command What it does When
/compact Compress context, keep summary Before starting a new task in a long session
/clear Full context wipe Switching to a completely different task
/cost Show token usage Check if context is getting full
/mcp List connected MCP servers Verify tools are loaded
/model Show or switch model Use faster model for simple tasks
/memory View/edit memory files Review what Claude has saved
/help All commands Reference

Other MCP Servers

Package Purpose
@modelcontextprotocol/server-postgres Query PostgreSQL
@modelcontextprotocol/server-brave-search Web search
@modelcontextprotocol/server-slack Slack messages

Browse all: https://github.com/modelcontextprotocol/servers


Config Files

File Purpose
~/.claude.json MCP servers, API key, global defaults
~/.claude/settings.json Auto-approve, theme, model
~/.claude/skills/ Custom slash commands
CLAUDE.md (project root) Project instructions — loaded every session

settings.json example

{
  "theme": "dark",
  "model": "claude-sonnet-4-6",
  "autoApprove": ["read", "glob", "grep", "bash(git *)"]
}

CLAUDE.md

Put a CLAUDE.md in your project root. Claude reads it at session start every time — use it for rules, stack info, and anything you'd otherwise repeat every session.


Memory System

Claude auto-saves context across sessions at ~/.claude/projects/<hash>/memory/.

Type Stores
user Your role, preferences, background
feedback Corrections and confirmed approaches
project Ongoing work, decisions, deadlines
reference Where to find things (dashboards, trackers)

Skills (Custom Commands)

Create ~/.claude/skills/my-skill.md:

---
name: my-skill
description: What it does
---

Steps for Claude to follow when invoked.

Invoke with /my-skill or /my-skill some args.


Effective Usage

  • Be specific upfront — "update the README, remove X, add Y" beats "update the readme" every time
  • Number your tasks — list 5 things as 1–5, not a paragraph; Claude tracks them in order
  • Correct immediately — don't let a wrong direction run for 3 messages
  • Use /compact proactively — after finishing a big task, before starting the next one
  • Multi-task in one message — Claude runs independent tasks in parallel, saves round trips
  • Use CLAUDE.md for rules — if you say the same thing every session, put it there instead

Keyboard Shortcuts

Shortcut Action
Esc Cancel current operation
Ctrl+C Exit
↑ / ↓ Navigate history
Shift+Enter New line in prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment