LLM: Claude Code in Action - Notes

17 January 2026, Carlos Pena

Reference: Claude Code in Action

1) CLAUDE.md (3 types)

Claude Code can read instructions from CLAUDE.md at different scopes:

✅ Global (User-level)

✅ Project (General)

✅ Local (Project-local / personal)

2) Referencing files with @filename / @path

Use @ to explicitly reference a file or path in prompts.

Example:

This is useful to:

3) “Set comment in memory” (sticky instructions)

You can write a note inside your instructions that Claude should remember and reuse.

Example:

# The database schema is defined in the @path/to/file.py file. Reference it anytime.

This pattern is great for:

4) Images: copy/paste support

Claude Code supports copy-pasting images directly into the conversation.

Useful for:

5) Thinking Mode (deeper reasoning)

You can trigger deeper reasoning by adding explicit thinking tags/phrases like:

Example prompt:

This is a tough task — ultrathink about the best approach and tradeoffs.

Notes:

6) Context management shortcuts

If Claude makes a mistake

Rewind conversation

Compact context

7) Custom commands (.claude/commands/)

You can create reusable “commands” inside:

.claude/commands/<command_name>.md

Example: audit.md

You goal is to update any vulnerable dependencies.
- Check lockfiles
- Upgrade safely
- Ensure builds/tests still pass
- Summarize changes + risks

Example: write_tests.md

Write comprehensive tests for: $ARGUMENT
- Follow project test conventions
- Prefer integration tests where useful
- Cover edge cases
- Include setup/teardown notes

Use cases:

8) MCP Servers (tools integration)

MCP servers let Claude use external tools safely (browser, filesystem, automation, etc).

Example: Playwright MCP Server

Playwright MCP allows Claude to:

Add it via CLI:

claude mcp add playwright npx ...

You can also allow/configure MCP in:

9) GitHub integrations

Enable Claude GitHub integration:

/install-github-app

Common capabilities

A) Mention Claude

B) Pull Request actions Claude can:

Workflow configuration (.github/workflows/claude.yml)

You can define project setup steps, like:

- name: Project Setup
  run: |
    npm run setup
    npm run dev:daemon

Add custom instructions (environment assumptions):

custom_instructions: |
  The project is already set up with all dependencies installed.
  The server is already running at localhost:3000.
  Logs are being written to logs.txt.
  If needed, you can query the db with the 'sqlite3' CLI.
  If needed, use the mcp__playwright toolset to interact with the app.

Example MCP config block:

mcp_config: |
  {
    "mcpServers": {
      "playwright": {
        "command": "npx",
        "args": [
          "@playwright/mcp@latest",
          "--allowed-origins",
          "localhost:3000;cdn.tailwindcss.com;esm.sh"
        ]
      }
    }
  }

Example allow-list of tools:

allowed_tools: "Bash(npm:*),Bash(sqlite3:*),mcp__playwright__browser_snapshot,mcp__playwright__browser_click,..."

10) Hooks (automation before/after actions)

Hooks let you run scripts before or after Claude uses tools.

You can set hooks:

Manage via:

/hooks

(or manually editing config files)

Example: PreToolUse

Runs before a tool executes.

Tool names you can hook into:

Security best practices for hooks (Must-do)

Example use case

Example: Automatically Run Sqlmesh Format After Sql Code Edits

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "(Edit|Write).*\\.sql",
        "hooks": [
          {
            "type": "command",
            "command": "uv run sqlmesh format",
            "timeout": 30,
            "description": "Auto-format SQLMesh models and tests after editing"
          }
        ]
      }
    ]
  }
}

Example: Automatically Run Ruff After Python Code Edits

You can automate code formatting and linting with Ruff after every code edit by configuring a post-edit hook in Claude.

1. Add a PostToolUse Hook in .claude/settings.json

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/run-ruff.sh"
          }
        ]
      }
    ]
  }
}

2. Create the run-ruff.sh Script

Note: Claude does not display logs, echo, or errors from hooks. For debugging, write output to a file (e.g., using echo or tee).

#!/bin/bash
input=$(cat)
file_path=$(echo "$input" | jq -r '.tool_input.file_path' 2>/dev/null)

# Only proceed if the file exists and is a Python file
if [[ -z "$file_path" || ! -f "$file_path" || "$file_path" != *.py ]]; then
  exit 0
fi

uv run ruff check --fix --unsafe-fixes "$file_path"
uv run ruff format "$file_path"
exit 0

Tips:

This setup ensures your Python files are automatically linted and formatted after each edit, keeping your codebase clean and consistent.


11) Other hook event types

Besides PreToolUse and PostToolUse, you can hook into:


12) Claude Code SDK (CLI / TypeScript / Python)

Claude Code SDK supports automation from:

Example (async):

from claude_code_sdk import query

async for message in query("look for duplicate queries"):
    print(message)

Example (sync):

import asyncio
from claude_code_sdk import query

async def main():
    async for message in query("look for duplicate queries"):
        print(message)

asyncio.run(main())