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.
What You'll Learn
This tutorial shows you how to build custom legal skills, add safety checks (hooks), and run multi-agent workflows. Some technical comfort is required.
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 |
UserPromptSubmit | Before prompt processing | Filter content |
Stop | When Claude finishes responding | 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 Scripts
~/.claude/hooks/pretool-privileged-guard.sh:
~/.claude/hooks/posttool-audit-log.sh:
Step 3: Configure Hook
~/.claude/settings.json:
Additional Hook Use Cases
Citation Verification Hook (Stop):
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 metadata and schema evolve quickly. Use the official plugins reference for the current manifest format, then map your legal assets into that structure.
Minimal hooks/hooks.json example:
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
Do This Now
- Create a custom skill for one of your firm's review processes
- Add at least one safety check (hook) for compliance or audit logging
- Test a multi-agent workflow for parallel document processing
- Document your skill so your team can use it
- Consider packaging as a plugin for distribution
Related family pages
Navigation
Quick Reference: Claude Code Commands
Sources
- Agent Skills Overview (Claude Docs)
- Agent Skills Quickstart (Claude Docs)
- Agent Skills Best Practices (Claude Docs)
- Use Skills in Claude Code
- Hooks Reference (Claude Code Docs)
- Plugins Reference (Claude Code Docs)