AI Coding Assistant Workflow Configuration: Five Component Types and an Implementation Checklist
This article explains how to configure a project-level workflow for an AI coding assistant using five component types: rules, subagents, skills, commands, and hooks. It describes what each component solves, provides configuration examples, and presents a three-phase rollout checklist with acceptance and rollback steps. It also covers permission boundaries, common mistakes, a pre-launch checklist, and next steps for ongoing maintenance.
Scope and Prerequisites
This article applies to AI coding assistants that support project-level configuration files and can mount hook scripts. The directory names (such as .ai/) and file names in this article are examples only; use the actual paths specified in the documentation for your tool. It is recommended to keep all configuration files under Git management so that every change can be reviewed through diffs and reverted.
1. What Each of the Five Component Types Solves
| Component | Purpose | Example output | Location (example) | Owner |
|---|---|---|---|---|
| Rules | Declare requirements that must be followed or prohibited | Security red lines, coding style clauses | .ai/rules/ |
Technical lead |
| Subagents | Dedicated sessions with a single responsibility | Security review agent | .ai/agents/ |
Developers using the agent |
| Skills | Fixed execution steps and output standards | Test-driven development workflow | .ai/skills/ |
Test lead |
| Commands | Trigger a fixed workflow with a short instruction | /security-audit |
.ai/commands/ |
Team initiating the workflow |
| Hooks | Run scripts before or after events such as file reads and writes | Check for plaintext secrets before write | .ai/hooks/ |
Operations or security staff |
Rules only declare requirements; they do not enforce them. Rules let the assistant know the standard, but the actual checks and modifications must be performed by commands or hooks, and the file scope must be limited.
2. Configuration Examples for Each Component
Rules. Rules should be written as checkable conditions. For example, “When test coverage is below 80%, output a reminder and list uncovered functions” is more useful than “Code should be high quality.” Store rule files separately by security, style, and testing so they can be adjusted independently.
Subagents. A subagent needs to specify its responsibilities, available tools, write access, and output format. Below is a minimal example:
name: security-reviewerrole: Check changed code for injection, privilege escalation, and plaintext secret issuestools: [read_file, grep, static_analyzer]write_access: noneoutput: JSON with fields file, line, severity (high/medium/low), issueboundary: Report issues only and do not modify files; mark as needs_review when a judgment cannot be made
The boundary section is important. When an agent without write access makes a mistake, the worst outcome is an incorrect report; it will not damage the code.
Skills. A skill fixes the steps for a task. A test-driven development skill can be written as follows:
- Write a failing test based on the requirement.
- Run the test and confirm that the failure reason matches the requirement.
- Write the minimal code to make the test pass.
- Run the full test suite and check for side effects.
- Output the coverage change for human review.
Commands. A command needs to specify the trigger, parameters, steps, and output location. For example:
Name: /security-auditParameters: --scope <directory>, default src/Steps:1. Read changed files within scope2. Call the security-reviewer subagent3. Write the report to reports/security-YYYYMMDD.md4. Do not modify any source code
If a command needs to automatically add tests, limit writes to the tests/ directory and request human confirmation before writing.
Hooks. Hooks run before a file is written. The following script assumes that the tool passes the path of the file to be written as the first argument; the specific interface depends on the tool:
#!/usr/bin/env bash# Check whether a file contains plaintext secrets before writingset -euo pipefailfile="$1"if grep -nE 'AKIA[0-9A-Z]{16}|BEGIN (RSA )?PRIVATE KEY' "$file"; thenprintf '{"hook":"pre_write_check","decision":"block","file":"%s"}\n' "$file" >&2exit 1fi
A hook should check only the files changed in the current operation, not scan the entire repository. Otherwise, every edit will wait for several seconds, and developers will quickly turn it off.
3. Phased Implementation Checklist
Phase 1: Foundation layer, rules and hooks active
- Steps: Create
.ai/rules/security.mdand write three security red lines; create.ai/hooks/pre_write_check.shand register it in the configuration. - Acceptance: On a test branch, write a fake secret
AKIAABCDEFGHIJKLMNOP; the hook must block the write and output one block log. - Rollback: Comment out the hook registration line and use
git checkout -- <file>to restore the modified file.
Phase 2: Workflow layer, commands and skills reusable
- Steps: Create
.ai/skills/tdd/SKILL.mdand.ai/commands/security-audit.md, following the format in Section 2. - Acceptance: Run
/security-auditin the sample repository; the report appears underreports/, andgit statusshows that the source code has not changed. - Rollback: Delete the command file. Files generated by the command in
reports/can be deleted as a group; confirm that the directory contains no human-created files before deleting.
Phase 3: Management layer, pass open items and constraints between sessions
- Steps: Create
.ai/memory/open-items.md. At the end of a session, run/wrap-upto append unfinished items to the file; add “read this file first” to the startup rules for new sessions. - Acceptance: After starting a new session, the assistant can restate the first open item from the previous list. Run the same batch of tests twice consecutively; results must match for the regression check to pass.
- Rollback: Remove the startup read rule. Keep the open-items file; do not delete it.
If a phase does not pass acceptance, do not move to the next phase.
4. Permission Boundaries and Common Mistakes
Three principles can be directly converted into configuration.
- Maintainable. Write the purpose, trigger scenario, owner, and last review date at the top of each configuration file.
- Least privilege. Allow writes to
tests/**, prohibit writes tosrc/core/**, and require human confirmation for other write operations. - Observable. Hook logs should include at least the timestamp, hook name, rule ID, decision (allow or block), file path, and reason. With a rule ID, you can trace which rule caused a particular block.
There are three common mistakes. First, rules are written too vaguely for the assistant to determine whether they have been violated. Second, configuration items accumulate and nobody deletes them, making behavior hard to predict; it is recommended to clean up rules that have never triggered once a month. Third, hook checks cover too large a scope and slow down editing; limit them to changed files.
Before launch, use the following checklist:
- Every configuration file has an owner
- All write operations have path allowlists
- Hook logs can be traced to specific rule IDs
- Configuration changes are reviewed and merged through Git
5. Next Three Steps
- Audit rule files monthly, delete rules that have never triggered, and merge rules with duplicate content.
- Turn operations that repeat twice or more in a week into command templates and add them to
.ai/commands/. - Sample hook logs weekly, count blocks and false positives, and adjust detection regexes accordingly.
