Sharpening Skills to Use Claude Code 05

Plan to outline output style, claude code hooks, github action and configuration including memory management. https://docs.anthropic.com/en/docs/claude-code/cli-reference

About hooks, Hooks in Claude Code are configurable shell commands that execute in response to events like tool calls. Here’s how to use them: Available Hook Types

  • Stop/SubagentStop: Runs when responses finish Configuration
  • PreToolUse: Runs before a tool executes
  • PostToolUse: Runs after tool completion
  • UserPromptSubmit: Runs when you submit a prompt
  • Notification: Runs on system notifications
  Configure in your settings JSON file:

  {
    "hooks": {
      "PreToolUse": [
        {
          "matcher": "Write",
          "hooks": [
            {
              "type": "command",
              "command": "echo 'About to write file'"
            }
          ]
        }
      ],
      "PostToolUse": [
        {
          "matcher": "Bash",
          "hooks": [
            {
              "type": "command",
              "command": "git add . && git commit -m 'Auto-commit after bash command'"
            }
          ]
        }
      ]
    }
  }

  Practical Examples

  Auto-formatting code:
  {
    "PostToolUse": [{
      "matcher": "Write|Edit",
      "hooks": [{
        "type": "command",
        "command": "black *.py"
      }]
    }]
  }

  Logging activities:
  {
    "PreToolUse": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "echo '$(date): Using tool' >> activity.log"
      }]
    }]
  }

  Hooks provide powerful customization - you can validate operations, add context, or automate workflows around Claude Code's actions.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.