HK-hub/AgentSkills / ax-audit
ax-audit
VerifiedAudits agentic applications for architecture and trust: tool parity, tool granularity, context injection, completion signals, approval gates, confidence cues, escape hatches, intent handshakes, memory visibility, and adaptive canvases. Produces a ship-readiness verdict plus an AX Relationship Summary. Use when reviewing agentic feature PRs or asking "is this agent-native", "AX review", "critique this AI feature", "does this earn user trust", or "audit this for AX". For traditional frontend UX use ui-audit.
rules-arch/granularity-workflow-shaped-tool.md
View on GitHub---
title: Tool bundles decision logic instead of being atomic
slug: granularity-workflow-shaped-tool
category: granularity
defaultTier: fix-this-sprint
surfaces: agent-tool-execution, agent-config
agent-native-principle: Granularity
detection: hybrid
related: granularity-static-api-mapping
---
## Tool bundles decision logic instead of being atomic
A tool like `analyze_and_organize(folder)` bundles judgment into code. Changing what "organize" means needs a code refactor, not a prompt edit, and the agent can't apply judgment to intermediate steps.
## What goes wrong
`analyze_and_organize_inbox` scans emails, decides importance, files them. User asks "Why did you archive that?" The agent can't change the logic: it's hardcoded. With atomic primitives, the agent decides itself.
## Detection
**Surfaces:** agent-tool-execution, agent-config
**Static signals:**
1. Grep tool definitions for compound names (`_and_`, `_then_`, `_with_`).
2. Check implementations for branching logic making domain decisions.
3. Count distinct API calls per tool; >1 suggests bundling.
**Concrete commands:**
```bash
rg 'name:\s*["\x27]\w+_(and|then|with)_\w+' --type=ts src/tools/
rg 'name:\s*["\x27](process|handle|manage|analyze|organize|auto)_' --type=ts src/tools/
rg -l 'tool\(|defineTool' --type=ts src/tools/ | while read f; do
rg -c --with-filename 'if\s*\(|switch\s*\(' "$f"
done | awk -F: '$2>3'
```
**False-positive guards:**
- Skip atomic transactions (e.g., `transfer_funds`) and `// ax-audit-ignore:granularity-workflow-shaped-tool`.
## Fix
Split into atomic primitives. Let the agent decide what to move and where.
```ts
// before: analyze_and_organize_inbox: after: atomic primitives
export const listEmails = tool({ name: "list_emails", /* ... */ });
export const readEmail = tool({ name: "read_email", /* ... */ });
export const moveEmail = tool({ name: "move_email", /* ... */ });
```
## Default tier and overrides
**Defaults to:** `fix-this-sprint`: works until the user disagrees with a bundled decision.
## Examples
**Anti-pattern (fails):**
```ts
export const processNewUser = tool({
name: "process_and_configure_new_user",
execute: async ({ email, name }) => {
const user = await api.post("/users", { email, name });
await api.post(`/users/${user.id}/roles`, { role: "member" }); // can't choose role
await api.post("/emails/send", { to: email, template: "welcome" }); // can't skip
},
});
```
**Applied (passes):**
```ts
export const createUser = tool({ name: "create_user", /* ... */ });
export const assignRole = tool({ name: "assign_role", /* ... */ });
export const sendEmail = tool({ name: "send_email", /* ... */ });
// Agent decides: skip welcome email, assign admin role
```
## Suppression
```ts
// ax-audit-ignore:granularity-workflow-shaped-tool, atomic transaction
export const transferFunds = tool({ name: "transfer_funds", /* ... */ });
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |