鱼皮AI导航
鱼皮AI导航
  • 主页
  • 社区
  • AI工具
  • AI知识库
  • AI提示词
  • MCP
  • Skills
  • AI学习资源
  • AI资讯
  • GitHub开源
登录/注册

code-review

面向 Pebble 代码库的深度代码审查能力,专注识别资源泄漏、并发竞争、迭代器误用、断言失效及规范合规性问题,覆盖 PR、diff 和变更集,确保数据一致性、内存安全与生产级健壮性。

测试与安全效率工具开发运维
访问 GitHub
文档Skills.MD
name
code-review
description
Review code, PRs, diffs, and changes in the Pebble codebase for correctness issues including resource leaks, concurrency bugs, iterator misuse, and lint violations. Use when asked to review code, a pull request, diff, or changes.

Pebble Code Review

Use this skill when asked to review code, a PR, diff, or changes in the Pebble codebase.

Priority: Critical Correctness Issues

These issues cause bugs, crashes, or data corruption. Flag immediately.

1. Resource Leaks

Get() returns a closer that MUST be closed:

▼
go
复制代码
// WRONG - memory leak val, _, err := db.Get(key) // CORRECT val, closer, err := db.Get(key) if err != nil { return err } defer closer.Close()

Iterators must be closed: This refers to database iterators or internal key-value iterators.

▼
go
复制代码
iter, _ := db.NewIter(nil) defer iter.Close() // Required

2. Concurrency Bugs

One iterator per goroutine:

▼
go
复制代码
// WRONG - race condition iter := db.NewIter(nil) go func() { iter.Next() }() // Goroutine 1 iter.First() // Goroutine 2 // CORRECT - separate iterators go func() { iter := db.NewIter(nil) defer iter.Close() // use exclusively }()

Lock release on panic:

▼
go
复制代码
// WRONG - deadlock if panic mu.Lock() doWork() mu.Unlock() // CORRECT mu.Lock() defer mu.Unlock() doWork()

3. Iterator Misuse

This section refers to key-value iterators (including base.InternalIterator), not to Go loop iterators.

Must position before accessing Key/Value:

▼
go
复制代码
// WRONG - undefined behavior iter := db.NewIter(nil) key := iter.Key() // Not positioned! // CORRECT iter := db.NewIter(nil) if iter.First() { key := iter.Key() }

Must check Error() after iteration:

▼
go
复制代码
// WRONG - silent failures for iter.First(); iter.Valid(); iter.Next() { process(iter.Key()) } // What if I/O error occurred? // CORRECT for iter.First(); iter.Valid(); iter.Next() { process(iter.Key()) } if err := iter.Error(); err != nil { return err }

4. Double-Close Panics

Many types panic on double-close. Use invariants.CloseChecker for new types:

▼
go
复制代码
type MyResource struct { closeCheck invariants.CloseChecker } func (r *MyResource) Close() error { r.closeCheck.Close() // Panics on double-close in invariant builds return r.underlying.Close() }

5. Bounds Checking

Use invariants package for safety:

▼
go
复制代码
// WRONG in hot paths if i >= len(slice) { panic("out of bounds") } // CORRECT - only panics in invariant builds invariants.CheckBounds(i, len(slice))

Priority: Required Patterns (Lint-Enforced)

These are caught by go test -tags invariants ./internal/lint but flag them in review.

Error Handling

▼
go
复制代码
// WRONG return fmt.Errorf("failed: %v", err) // CORRECT - preserves stack traces return errors.Errorf("failed: %v", err) return errors.Wrap(err, "context")

Atomic Operations

▼
go
复制代码
// WRONG - alignment issues, not type-safe var count uint64 atomic.StoreUint64(&count, 10) // CORRECT var count atomic.Uint64 count.Store(10)

Finalizers

▼
go
复制代码
// WRONG runtime.SetFinalizer(obj, cleanup) // CORRECT - controlled, testable invariants.SetFinalizer(obj, cleanup)

OS Error Checks

▼
go
复制代码
// WRONG if os.IsNotExist(err) { ... } // CORRECT if oserror.IsNotExist(err) { ... }

Forbidden Imports

  • errors → use github.com/cockroachdb/errors
  • pkg/errors → use github.com/cockroachdb/errors
  • golang.org/x/exp/slices → use slices (builtin)
  • golang.org/x/exp/rand → use math/rand/v2

Priority: Corruption Prevention

Corruption Errors

Mark errors appropriately so they can be detected:

▼
go
复制代码
// For data corruption return base.CorruptionErrorf("invalid key: %s", key) // To check if base.IsCorruptionError(err) { // Handle corruption }

Invariant Checks

Use invariants for assertions that should hold:

▼
go
复制代码
if invariants.Enabled { if unexpectedCondition { panic("invariant violated: ...") } }

CockroachDB Conventions

Error Wrapping

Always add context when wrapping:

▼
go
复制代码
// WRONG return err // CORRECT return errors.Wrap(err, "loading manifest") return errors.Wrapf(err, "reading block %d", blockNum)

Redact Safety

Use redact.SafeFormat for types that may contain user data:

▼
go
复制代码
func (k Key) SafeFormat(w redact.SafePrinter, _ rune) { w.Print(redact.SafeString(k.String())) }

TODO Attribution

Always attribute TODOs:

▼
go
复制代码
// TODO(username): description of future work

Review Checklist

When reviewing, verify in order:

  1. Resource Management

    • All Get() callers close the returned closer
    • All iterators are closed
    • No double-close potential
  2. Concurrency

    • Iterators not shared across goroutines
    • Locks released via defer
    • Atomic types used (not raw atomic ops)
  3. Error Handling

    • Errors not silently ignored
    • iter.Error() checked after loops
    • Using errors.Errorf not fmt.Errorf
  4. Safety

    • No potential nil dereferences
    • Bounds checked where needed
    • Corruption marked appropriately
  5. Lint Compliance

    • No forbidden imports
    • oserror not os.Is*
    • invariants.SetFinalizer not runtime.SetFinalizer

Commit Message Format

When reviewing commit messages:

  • Subject: package: short description (lowercase after colon)
  • Body: Explain "what existed before" and "why"
  • No test plan unless explicitly requested

Good examples:

▼
text
复制代码
bloom: improve simulation output db: add progressive bloom filter policy internal/manifest: rename LevelFile to LevelTable
测试与安全
效率工具
开发运维

快捷安装

复制到终端去安装 Skill

npxskillsaddcockroachdb/pebble--skill"code-review"
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
🔥热门工具
朱雀AI检测朱雀AI检测
朱雀AI检测助手朱雀AI检测助手
LovartLovart
老鱼简历老鱼简历
WritePass官网WritePass官网
面多多面多多
CursorCursor
星月写作星月写作
朱雀AI检测助手朱雀AI检测助手
零感AI零感AI
Skills 推荐
debug
debug 是一个系统化定位软件缺陷根因的技能,适用于用户报告 'fix'、'broken'、'error' 等问题或测试意外失败时。它通过可验证的假设、最小复现、因果链分析和回归测试,确保在修复前准确定位根本原因。
retrieving-developer-knowledge
retrieving-developer-knowledge 用于搜索、获取和整合 Google 官方开发者文档,覆盖 Google Cloud、AI/Gemini、Android、Chrome、Web、Flutter、Go、Firebase 等平台,适用于查询 gcloud CLI 命令、API 语法、IAM 权限或架构对比等场景。
diff-intake
diff-intake 读取 PR 或分支差异,生成结构化 YAML 变更摘要,用于下游 analytics instrumentation 技能。适用于用户提交 PR 链接、分支对比或原始 diff 后需理解变更内容、评估分析覆盖或启动埋点流程的场景。
load-balancer-configurator
根据用户需求自动生成各类负载均衡器的生产级配置,覆盖 ALB、NLB、Nginx 和 HAProxy 等主流类型,适配不同协议、端口、健康检查及后端服务拓扑,支持直接集成到基础设施即代码流程中。
webapp-testing
提供本地 Web 应用的端到端测试能力,支持页面导航、元素交互、表单填写、动态等待、断言验证、截图捕获、浏览器日志收集及网络请求拦截,适用于前端功能验证与 UI 行为调试。