
Tighten Claude Code in Your Repo: workflowSizeGuideline and the DirectoryAdded Hook
Chris Harper
3 min read
Jul 25, 2026 · 12:04 UTC
TL;DR: Claude Code v2.1.219 adds two settings that give your team finer control — workflowSizeGuideline caps multi-agent fleet size project-wide, and the DirectoryAdded hook auto-runs setup scripts whenever a new workspace directory joins a session.
workflowSizeGuideline: right-size workflows for your project
Claude Code's dynamic workflow system picks a fleet size for multi-agent tasks automatically. By default it uses the session's advisory guideline (configurable in /config), but that setting isn't committed to your repo — every developer can silently drift.
The new workflowSizeGuideline key fixes that. Set it in .claude/settings.json and it overrides the user-level /config value for anyone working in that repo:
{
"workflowSizeGuideline": "small"
}
Valid values: "small" · "medium" · "large". When a project-level value is set, the /config row for this setting is hidden so no one accidentally overrides it locally.
When to use each:
| Value | Best for |
|---|---|
"small" | Cost-sensitive projects, focused CI tasks, repos where most work is single-file |
"medium" | General development — the default if unset |
"large" | Monorepo refactors, multi-service migrations, comprehensive audits |
For most teams, commit "small" or "medium" to start, then bump up per-project when you have a legitimate use for larger fleets. This keeps token spend predictable across your whole engineering org.
DirectoryAdded hook: per-workspace setup in monorepos
The DirectoryAdded lifecycle hook fires whenever /add-dir or the SDK register_repo_root call brings a new directory into the active session. It's the missing piece for monorepo setups where each workspace has its own deps or linting config.
Add it alongside your other hooks in .claude/settings.json:
{
"hooks": {
"DirectoryAdded": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "bash .claude/hooks/on-dir-added.sh \"$CLAUDE_ADDED_DIR\""
}
]
}
]
}
}
Example .claude/hooks/on-dir-added.sh:
#!/usr/bin/env bash
# Runs when a new directory is registered in a Claude Code session
DIR="$1"
cd "$DIR" || exit 0
# Install workspace deps if a package file exists
if [ -f package.json ]; then
echo "Installing node deps for $DIR..."
pnpm install --frozen-lockfile --silent
fi
if [ -f pyproject.toml ] || [ -f requirements.txt ]; then
echo "Setting up Python env for $DIR..."
uv sync --quiet 2>/dev/null || pip install -r requirements.txt -q
fi
The hook receives the added directory path as $CLAUDE_ADDED_DIR. Keep the script fast — it runs synchronously before Claude gets context from the new directory.
Why it matters: without this hook, Claude enters a new workspace cold. With it, deps are already installed, linters are configured, and any per-workspace validation you care about has already run — Claude's first action in that directory is never "install deps."
Sources: Claude Code Changelog · Claude Code Hooks guide — DataCamp · Complete Hooks Guide — claudefa.st