ln-652-transaction-correctness-auditor by levnikolaevich/claude-code-skills
npx skills add https://github.com/levnikolaevich/claude-code-skills --skill ln-652-transaction-correctness-auditorPaths: File paths (
shared/,references/,../ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root. Ifshared/is missing, fetch files via WebFetch fromhttps://raw.githubusercontent.com/levnikolaevich/claude-code-skills/master/skills/{path}.
专门用于审计数据库事务模式在正确性、范围和触发器交互方面的 Worker。
必读: 加载 shared/references/audit_worker_core_contract.md。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
接收包含以下内容的 contextStore:tech_stack、best_practices、db_config(数据库类型、ORM 设置、触发器/通知模式)、codebase_root、output_dir。
领域感知: 支持 domain_mode + current_domain。
必读: 加载 shared/references/two_layer_detection.md 了解检测方法。
pg_notify、CREATE TRIGGER、NOTIFY)expire_on_commit、autocommit、隔离级别)shared/templates/audit_worker_report_template.md 在内存中构建完整的 Markdown 报告,通过单次 Write 调用写入 {output_dir}/652-transaction-correctness.md描述: 当数据库触发器/NOTIFY 依赖于事务提交时,执行 UPDATE 操作但没有提交。
检测方法:
alembic/versions/、migrations/ 中搜索 pg_notify|NOTIFY|CREATE TRIGGER|CREATE OR REPLACE FUNCTION.*triggerrepo.*update|session\.execute.*update|\.progress|\.statuscommit():
commit(),则 NOTIFY 事件将延迟到最终提交时才发出严重性:
例外: 单个原子操作,没有中间可观察状态 → 将严重性从严重降级为中等。事务范围被记录为有意为之(ADR、架构注释)→ 降一级。
建议:
session.commit()(需节流:每 N%、每 T 秒)工作量: 小-中(添加策略性提交或重新设计通知路径)
描述: 单个事务包装了不相关的操作,包括缓慢的外部调用。
检测方法:
async with session.begin() 或显式的事务块await httpx.、await aiohttp.、await requests.、await grpc.open(、.read(、.write(严重性:
建议: 拆分为独立的事务;使用 Saga/Outbox 模式实现跨服务一致性。
工作量: 中-大(重构事务边界)
描述: 逻辑上原子的操作被拆分为多个提交。
检测方法:
session.commit() 调用严重性:
建议: 使用 async with session.begin() 或工作单元模式将相关操作包装在单个事务中。
工作量: 中(重构提交边界)
描述: session.commit() 没有适当的错误处理和回滚。
检测方法:
try/except 块或上下文管理器内的 session.commit()try 中但没有在 except 中执行 session.rollback() 的 session.commit()await session.commit()async with session.begin() 自动回滚(安全)严重性:
建议: 使用 async with session.begin()(自动回滚),或添加显式的 try/except/rollback 模式。
工作量: 小(包装在上下文管理器中或添加错误处理)
描述: 在缓慢/阻塞操作期间事务保持打开状态。
检测方法:
begin() 和 commit() 之间有超过 50 行代码,则标记await 调用(网络延迟),则标记time.sleep() 或 asyncio.sleep(),则标记严重性:
建议: 最小化事务范围;在打开事务之前准备数据,在数据库操作后立即提交。
工作量: 中(重构代码以最小化事务窗口)
描述: 发布者通道/主题名称与订阅者通道/主题名称不匹配。
检测方法:
pg_notify('channel_name', ...)、NOTIFY channel_name 中提取字符串参数src/、app/ 中搜索 \.publish\(["']|\.emit\(["']|redis.*publish\(["']|\.send_to\(["']{channel_name, source_file, source_line, technology}LISTEN\s+(\w+)src/、app/ 中搜索 \.subscribe\(["']([^"']+)\.on\(["']([^"']+){channel_name, source_file, source_line, technology}publisher.channel_name == subscriber.channel_name → 正常第二层上下文分析(必做):
CHANNEL = os.environ["EVENT_CHANNEL"])并且发布者和订阅者使用相同的来源 → 不是不匹配job_events:{job_id})并且双方使用相同的模板 → 不是孤立**/test*/**、**/*.test.*)严重性:
job_events,订阅者监听 job_event)建议:
工作量: 小(修复拼写错误/添加常量)到中(设计缺失的订阅者/发布者)
必读: 加载 shared/references/audit_worker_core_contract.md 和 shared/references/audit_scoring.md。
必读: 加载 shared/references/audit_worker_core_contract.md 和 shared/templates/audit_worker_report_template.md。
将报告写入 {output_dir}/652-transaction-correctness.md,其中包含 category: "Transaction Correctness" 和检查项:missing_intermediate_commits、scope_too_wide、scope_too_narrow、missing_rollback、long_held_transaction、event_channel_consistency。
向协调器返回摘要:
Report written: docs/project/.audit/ln-650/{YYYY-MM-DD}/652-transaction-correctness.md
Score: X.X/10 | Issues: N (C:N H:N M:N L:N)
必读: 加载 shared/references/audit_worker_core_contract.md。
async with session.begin() 是安全的)必读: 加载 shared/references/audit_worker_core_contract.md。
{output_dir}/652-transaction-correctness.md(原子性单次 Write 调用)shared/references/audit_output_schema.md版本: 1.1.0 最后更新: 2026-03-15
每周安装次数
139
代码仓库
GitHub 星标数
245
首次出现
2026年2月7日
安全审计
安装于
claude-code129
cursor128
opencode128
codex127
gemini-cli127
github-copilot126
Paths: File paths (
shared/,references/,../ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root. Ifshared/is missing, fetch files via WebFetch fromhttps://raw.githubusercontent.com/levnikolaevich/claude-code-skills/master/skills/{path}.
Specialized worker auditing database transaction patterns for correctness, scope, and trigger interaction.
MANDATORY READ: Load shared/references/audit_worker_core_contract.md.
Receives contextStore with: tech_stack, best_practices, db_config (database type, ORM settings, trigger/notify patterns), codebase_root, output_dir.
Domain-aware: Supports domain_mode + current_domain.
MANDATORY READ: Load shared/references/two_layer_detection.md for detection methodology.
Parse context from contextStore
Discover transaction infrastructure
pg_notify, CREATE TRIGGER, NOTIFY)expire_on_commit, autocommit, isolation level)Scan codebase for violations
Collect findings with severity, location, effort, recommendation
What: UPDATE without commit when DB trigger/NOTIFY depends on transaction commit
Detection:
pg_notify|NOTIFY|CREATE TRIGGER|CREATE OR REPLACE FUNCTION.*trigger in alembic/versions/, migrations/repo.*update|session\.execute.*update|\.progress|\.status related to trigger tablescommit() between sequential updates:
commit(), NOTIFY events are deferred until final commitSeverity:
Exception: Single atomic operation with no intermediate observable state → downgrade CRITICAL to MEDIUM. Transaction scope documented as intentional (ADR, architecture comment) → downgrade one level
Recommendation:
session.commit() at progress milestones (throttled: every N%, every T seconds)Effort: S-M (add strategic commits or redesign notification path)
What: Single transaction wraps unrelated operations, including slow external calls
Detection:
async with session.begin() or explicit transaction blocksawait httpx., await aiohttp., await requests., await grpc.open(, .read(, .write(Severity:
Recommendation: Split into separate transactions; use Saga/Outbox pattern for cross-service consistency
Effort: M-L (restructure transaction boundaries)
What: Logically atomic operations split across multiple commits
Detection:
session.commit() calls for operations that should be atomicSeverity:
Recommendation: Wrap related operations in single transaction using async with session.begin() or unit-of-work pattern
Effort: M (restructure commit boundaries)
What: session.commit() without proper error handling and rollback
Detection:
session.commit() not inside try/except block or context managersession.commit() in try without session.rollback() in exceptawait session.commit() in service methodsasync with session.begin() auto-rollbacks (safe)Severity:
Recommendation: Use async with session.begin() (auto-rollback), or add explicit try/except/rollback pattern
Effort: S (wrap in context manager or add error handling)
What: Transaction open during slow/blocking operations
Detection:
begin() and commit()await calls to external services (network latency)time.sleep() or asyncio.sleep()Severity:
Recommendation: Minimize transaction scope; prepare data before opening transaction, commit immediately after DB operations
Effort: M (restructure code to minimize transaction window)
What: Publisher channel/topic name does not match subscriber channel/topic name
Detection:
pg_notify('channel_name', ...), NOTIFY channel_name\.publish\(["']|\.emit\(["']|redis.*publish\(["']|\.send_to\(["'] in src/, app/{channel_name, source_file, source_line, technology}LISTEN\s+(\w+) in application code (not just migrations)\.subscribe\(["']([^"']+) in , Layer 2 Context Analysis (MANDATORY):
CHANNEL = os.environ["EVENT_CHANNEL"]) and both publisher and subscriber use same source → NOT a mismatchjob_events:{job_id}) and both sides use same template → NOT orphaned**/test*/**, **/*.test.*) from both publisher and subscriber discoverySeverity:
job_events, subscriber listens on job_event)Recommendation:
Effort: S (fix typo/add constant) to M (design missing subscriber/publisher)
MANDATORY READ: Load shared/references/audit_worker_core_contract.md and shared/references/audit_scoring.md.
MANDATORY READ: Load shared/references/audit_worker_core_contract.md and shared/templates/audit_worker_report_template.md.
Write report to {output_dir}/652-transaction-correctness.md with category: "Transaction Correctness" and checks: missing_intermediate_commits, scope_too_wide, scope_too_narrow, missing_rollback, long_held_transaction, event_channel_consistency.
Return summary to coordinator:
Report written: docs/project/.audit/ln-650/{YYYY-MM-DD}/652-transaction-correctness.md
Score: X.X/10 | Issues: N (C:N H:N M:N L:N)
MANDATORY READ: Load shared/references/audit_worker_core_contract.md.
async with session.begin() is safe)MANDATORY READ: Load shared/references/audit_worker_core_contract.md.
{output_dir}/652-transaction-correctness.md (atomic single Write call)shared/references/audit_output_schema.mdVersion: 1.1.0 Last Updated: 2026-03-15
Weekly Installs
139
Repository
GitHub Stars
245
First Seen
Feb 7, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
claude-code129
cursor128
opencode128
codex127
gemini-cli127
github-copilot126
通过 LiteLLM 代理让 Claude Code 对接 GitHub Copilot 运行 | 高级变通方案指南
36,300 周安装
多智能体编排策略指南:从597+真实调度提炼的元编排模式与提示词构建
137 周安装
Info Card Designer - 自动生成杂志质感信息卡,适配X/Twitter、小红书分享,支持内容密度分析与超长分割
137 周安装
头脑风暴助手 - 使用Gemini AI系统生成创意想法,支持SCAMPER、六顶思考帽等方法
137 周安装
运行时性能审计器 - 异步代码性能优化与反模式检测工具
137 周安装
ln-723 种子数据生成器:多语言ORM模式解析与智能测试数据生成工具
137 周安装
Symfony测试替身模拟指南:TDD、PHP单元测试与Mocking实践
137 周安装
Write Report: Build full markdown report in memory per shared/templates/audit_worker_report_template.md, write to {output_dir}/652-transaction-correctness.md in single Write call
Return Summary: Return minimal summary to coordinator (see Output Format)
src/app/\.on\(["']([^"']+) in handler/listener directories{channel_name, source_file, source_line, technology}publisher.channel_name == subscriber.channel_name → OK