Tutorial 09: Custom Legal Skills, Hooks & Agents
Build custom skills for your firm's workflows, create compliance hooks, and deploy multi-agent systems for complex legal tasks.
Expert Level
Developer skills recommended. Estimated time: 120 minutes.
Learning Objectives
By the end of this tutorial, you will:
- Understand Claude Code's architecture (Skills, Hooks, Sub-agents)
- Build custom legal skills for your firm's workflows
- Create hooks for quality control and compliance
- Deploy multi-agent systems for complex legal tasks
Part 1: Understanding the Claude Code Stack
Architecture Overview
Why This Matters for Legal
| Component | Legal Application |
|---|---|
| Skills | Encode playbooks, review procedures, drafting standards |
| Hooks | Enforce compliance, prevent unauthorized actions, audit logging |
| Sub-agents | Parallelize document review, research tasks |
| Plugins | Package firm workflows for distribution |
Part 2: Building Custom Legal Skills
What Are Skills?
Skills are specialized instructions stored in files that Claude reads based on context. Unlike prompts (one-time), Skills persist and activate automatically.
Skill File Structure
Creating a Contract Review Skill
Step 1: Create Skill Directory
Step 2: Write SKILL.md
Step 3: Create Playbook Resource
resources/playbook.json:
Step 4: Create Clause Library
resources/clause-library.md:
Step 5: Install and Test
Part 3: Building Compliance Hooks
What Are Hooks?
Hooks are scripts that execute at specific points in Claude's operation:
| Hook Type | Trigger Point | Use Case |
|---|---|---|
PreToolUse | Before any tool runs | Block dangerous actions |
PostToolUse | After tool completes | Audit logging |
SessionStart | When session begins | Load context |
PreInput | Before processing input | Filter content |
PostOutput | After generating output | Quality checks |
Legal Compliance Hook Example
Purpose: Prevent Claude from making unauthorized changes to privileged documents.
Step 1: Create Hook Directory
Step 2: Create Hook Script
~/.claude/hooks/legal-compliance.js:
Step 3: Configure Hook
~/.claude/settings.json:
Additional Hook Use Cases
Citation Verification Hook:
Confidentiality Check Hook:
Part 4: Multi-Agent Legal Workflows
Understanding Sub-Agents
Claude can spawn sub-agents to handle specific tasks:
- Parallelization: Multiple documents reviewed simultaneously
- Specialization: Different agents for different tasks
- Isolation: Separate context for separate analyses
Example: Parallel Due Diligence Review
Example: Research + Draft Workflow
Part 5: Packaging Skills into Plugins
Plugin Structure
Plugin Manifest
plugin.json:
Installing and Distributing
Part 6: Security Considerations
Skill Security
- Source verification: Only install skills from trusted sources
- Code review: Review all hook code before deployment
- No client data: Never include client data in skill files
- Version control: Track changes to skills
- Access control: Limit who can modify firm skills
Data Protection
Compliance Requirements
- Skills reviewed by IT security
- Hooks tested in sandbox environment
- Audit logging enabled
- Client data segregation verified
- Access controls configured
- Backup procedures documented
Homework Before Tutorial 10
-
Create a custom skill for one of your firm's review processes
-
Implement at least one hook (compliance or audit logging)
-
Test a multi-agent workflow for parallel document processing
-
Document your skill for team adoption
-
Consider packaging as a plugin for distribution