协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
ai-commenting【开发与工程】AI-native code annotation protocol that encodes intent, risk, dependencies, constraints, and test expectations in machine-parseable comments.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Codex supports native subagents. Delegate with spawn_agent, coordinate with send_input, collect via wait_agent, and clean up with close_agent.
Execution preference:
[ANALYST]/[ARCHITECT]/[EXECUTOR]/[REVIEWER] structure in a single response.Minimal orchestration pattern:
spawn_agent -> send_input (optional) -> wait_agent -> close_agent
Create and maintain AI-native annotations so models can understand project intent quickly and safely, not just code syntax.
Traditional comments are optimized for human reading, but LLM coding agents need dense, structured context to avoid unsafe edits and repeated discovery work.
This skill defines a compact annotation protocol that turns files into a machine-readable context layer for:
Use these principles when writing AI annotations:
why and constraints, not obvious what.Canonical format (single line):
/*@ai:key=value|key=value|key=value*/
Rules:
|.=.AuthService, integration, p95<200ms).Core fields (recommended at file level):
risk=1-5: change risk (5 is highest)core=<domain>: core responsibility (UserCRUD, BillingLedger)deps=<A,B,C>: critical dependenciesintent=<why>: non-obvious business intenttest=<unit|integration|e2e|contract>: minimum test gateExtended fields (use when needed):
chain=<A->B->C>: business or data flow chainasync=<low|medium|complex>: async/concurrency complexityapi=<internal|external>: API boundary typeauth=<none|required|strict>: authorization levelinvariant=<must_hold>: critical invariantsidefx=<db,cache,queue,event>: side effectsperf=<budget>: performance constraint (p95<200ms)security=<pii|payment|secret|none>: security sensitivityowner=<team_or_module>: ownership hintrollback=<strategy>: safe fallback strategyticket=<id>: change traceabilityOptional maintenance fields:
lines=<N|500+>: file size hintupdated=<YYYY-MM-DD>: annotation freshnessrisk present)risk=1: isolated logic, low coupling, fast rollbackrisk=2: local impact, clear tests, low side effectsrisk=3: moderate coupling or external contract dependencyrisk=4: cross-module critical path, data/auth impactrisk=5: security/payment/core-state changes, high blast radiusEscalate risk by +1 when any condition applies:
For high-value modules, ensure annotations expose these context dimensions:
intent, core)invariant, perf, security)deps, chain, sidefx)api, auth)test)risk, rollback, owner)If the model can read these fields, it can plan edits with less guesswork.
Use a two-layer strategy:
risk, core, deps, intent, test.invariant, auth, sidefx, perf).Do not annotate every function. Keep density high-signal.
Example from your draft (fully valid):
/*@ai:risk=4|deps=UserModel,AuthService,Database|lines=500+|core=UserCRUD*/
/*@ai:chain=Auth->User->Permission->Audit|async=complex|test=integration*/
class UserManager {
// ...
}
Recommended enriched version:
/*@ai:risk=5|core=UserCRUD|intent=protect_user_consistency|deps=UserModel,AuthService,AuditService*/
/*@ai:chain=Auth->User->Permission->Audit|auth=strict|sidefx=db,event|test=integration|rollback=feature_flag*/
class UserManager {
/*@ai:risk=4|invariant=user_id_unique|security=pii|perf=p95<200ms*/
async deleteUser(userId: string) {
// ...
}
}
When asked to annotate a module:
/*@ai:...*/ format.test and rollback are present for risk>=4.Minimum acceptance:
risk>=4 files have file-level @ai annotations.risk>=4 block includes test or inherits explicit file-level test.security!=none implies auth!=none and a rollback strategy.updated= recommended).Density guidance:
Avoid:
auth=none and security=pii).intent.Use these regex patterns when extracting annotations:
const aiTagPattern = /\/\*@ai:([^*]+)\*\//g;
const fieldPattern = /(\w+)=([^|*]+)/g;
Normalize output to key-value JSON for downstream retrieval and risk maps.
When this skill completes, return:
Result summary: what annotation protocol was appliedFiles changed: absolute file pathsValidation evidence: parser/lint/check commands and outcomesRisks / next actions: unresolved safety/test gaps