Skip to content

CloudNimble/ClaudeEssentials

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClaudeEssentials

NuGet Build

AOT-ready .NET models for building Claude Code hook processors.

What It Does

Claude Code hooks let you intercept and customize Claude's behavior. ClaudeEssentials provides strongly-typed C# models for all hook events, with source-generated JSON serialization for instant startup.

Installation

dotnet add package ClaudeEssentials

Quick Example

using CloudNimble.ClaudeEssentials.Hooks;
using CloudNimble.ClaudeEssentials.Hooks.Enums;
using CloudNimble.ClaudeEssentials.Hooks.Outputs;

// Read JSON from stdin
var json = Console.In.ReadToEnd();
var input = ClaudeHooksSerializer.DeserializePreToolUseInput(json);

// Auto-approve read-only tools
var output = new PreToolUseHookOutput<object>
{
    Continue = true,
    HookSpecificOutput = new PreToolUseSpecificOutput<object>
    {
        PermissionDecision = input.ToolName is "Read" or "Glob"
            ? PermissionDecision.Allow
            : PermissionDecision.Ask
    }
};

// Write response to stdout
Console.WriteLine(ClaudeHooksSerializer.SerializePreToolUseOutput(output));

Supported Hooks

Hook Purpose
PreToolUse Approve, deny, or modify tool calls before execution
PostToolUse Add context or take action after tools complete
Stop Enforce policies before Claude ends a session
SessionStart Inject project context when sessions begin
Notification React to permission prompts and notifications
UserPromptSubmit Process user prompts before they're sent
PreCompact Customize context compaction behavior

Features

  • AOT Ready - Source-generated serialization, zero reflection
  • Strongly Typed - Full IntelliSense and compile-time safety
  • Lightweight - No dependencies beyond System.Text.Json

Documentation

Full documentation available at easyaf.dev/claudeessentials

License

MIT

About

A C# library for building Claude Code Hooks

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published