Token导航 LogoToken导航

Agent Skill · 研究检索

go-repository(去存储库)

用于围绕 GitHub 仓库、Issue、Pull Request、分支、提交和代码协作流程提供辅助能力。它适合让 Agent 查询项目状态、整理变更、辅助创建或检查协作事项,并把仓库中的信息转成可执行的下一步。使用时需要区分只读查询和写入操作;涉及创建 PR、修改 Issue、推送分支或访问私有仓库时,应确认 token 权限、目标仓库范围和用户授权。

go-repository 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为权限未标注;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 58,892。

总安装 399周安装 16GitHub Stars 公开资料未说明下载 129核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:go-repository(去存储库)
来源仓库:https://github.com/cristiano-pacheco/ai-tools
仓库路径:skills/go-repository
安装命令:
npx skills add https://github.com/cristiano-pacheco/ai-tools --skill go-repository
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/cristiano-pacheco/ai-tools --skill go-repository

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于围绕 GitHub 仓库、Issue 和 PR 提供协作辅助能力。适合查询项目状态、整理变更和创建协作事项等场景。可把仓库信息转成可执行的操作建议。go-repository 属于研究检索类 Skill,可作为该场景下的辅助能力补充。涉及写入操作时应确认 token 权限和仓库范围。

安装前建议确认来源仓库维护状态和权限范围。

来源仓库内路径:skills/go-repository

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/cristiano-pacheco/ai-tools --skill go-reposito…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    权限没有明确标注,第一次使用时只给一个无关紧要的任务,观察它到底读了哪些文件和网络。

常见问题

6 条

go-repository 怎么安装?

在终端执行 npx skills add https://github.com/cristiano-pacheco/ai-tools --skill go-repository。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

go-repository 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

go-repository 需要什么权限?

权限级别没有明确标注。第一次使用时建议只给无关紧要的任务,观察它实际读写了哪些内容。

go-repository 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

go-repository 用的人多吗?

公开数据是累计安装 399 次,近一周安装 16 次,下载 129 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

go-repository 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
go-repository

去存储库 · 本页

399—权限未标注未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Go Repository

Generate repository port interfaces and implementations for Go modular architecture conventions.

When to Use

  • Create data access layers for entities
  • CRUD operations (Create, FindAll, FindByID, Update, Delete)
  • Custom queries, pagination, transactions
  • Join queries and filtered lookups

Two-File Pattern

Every repository requires two files:

  1. Port interface: internal/modules/<module>/ports/<entity>_repository.go
  2. Repository implementation: internal/modules/<module>/repository/<entity>_repository.go

Port Interface Structure

Location: internal/modules/<module>/ports/<entity>_repository.go

package ports

import (
	"context"
	"github.com/cristiano-pacheco/pingo/internal/modules/<module>/model"
)

// EntityRepository defines entity persistence operations.
//
// Add a comprehensive comment here describing the purpose of the repository,
// what domain concept it represents, and any non-obvious behavior.
type EntityRepository interface {
	FindAll(ctx context.Context) ([]model.EntityModel, error)
	FindByID(ctx context.Context, id uint64) (model.EntityModel, error)
	Create(ctx context.Context, entity model.EntityModel) (model.EntityModel, error)
	Update(ctx context.Context, entity model.EntityModel) (model.EntityModel, error)
	Delete(ctx context.Context, id uint64) error
}

Pagination variant:

FindAll(ctx context.Context, page, pageSize int) ([]model.EntityModel, int64, error)

Custom methods: Add domain-specific queries as needed (e.g., FindByName, FindBySKU).

Repository Implementation Structure

Location: internal/modules/<module>/repository/<entity>_repository.go

package repository

import (
	"context"
	"errors"

	brickserrs "github.com/cristiano-pacheco/bricks/pkg/errs"
	"github.com/cristiano-pacheco/bricks/pkg/otel/trace"
	"github.com/cristiano-pacheco/pingo/internal/modules/<module>/model"
	"github.com/cristiano-pacheco/pingo/internal/modules/<module>/ports"
	"github.com/cristiano-pacheco/pingo/internal/shared/database"
	"gorm.io/gorm"
)

type EntityRepository struct {
	*database.PingoDB
}

var _ ports.EntityRepository = (*EntityRepository)(nil)

func NewEntityRepository(db *database.PingoDB) *EntityRepository {
	return &EntityRepository{PingoDB: db}
}
Note: The constructor MUST use named field initialization {PingoDB: db}, not positional {db}.

Method Implementations

FindAll (Simple)

func (r *EntityRepository) FindAll(ctx context.Context) ([]model.EntityModel, error) {
	ctx, span := trace.Span(ctx, "EntityRepository.FindAll")
	defer span.End()

	entities, err := gorm.G[model.EntityModel](r.DB).Find(ctx)
	if err != nil {
		return nil, err
	}
	return entities, nil
}

FindAll (Paginated with dynamic filters)

When you need optional WHERE filters or pagination, fall back to raw GORM — gorm.G does not support dynamic multi-condition builds. Use r.DB.WithContext(ctx).Model(...) for these cases:

func (r *EntityRepository) FindAll(
	ctx context.Context,
	filter dto.EntityFilter,
	paginationParams paginator.Params,
) ([]model.EntityModel, int64, error) {
	ctx, span := trace.Span(ctx, "EntityRepository.FindAll")
	defer span.End()

	baseQuery := r.DB.WithContext(ctx).Model(&model.EntityModel{})
	if filter.Status != "" {
		baseQuery = baseQuery.Where("status = ?", filter.Status)
	}
	if filter.Name != nil && strings.TrimSpace(*filter.Name) != "" {
		baseQuery = baseQuery.Where("name ILIKE ?", "%"+strings.TrimSpace(*filter.Name)+"%")
	}

	var totalCount int64
	if err := baseQuery.Count(&totalCount).Error; err != nil {
		return nil, 0, err
	}

	query := baseQuery.Order("id DESC")
	if paginationParams.Limit() > 0 {
		query = query.Limit(paginationParams.Limit())
	}
	if paginationParams.Offset() > 0 {
		query = query.Offset(paginationParams.Offset())
	}

	results := make([]model.EntityModel, 0)
	if err := query.Find(&results).Error; err != nil {
		return nil, 0, err
	}

	return results, totalCount, nil
}

FindAll (JOIN query)

For queries that require JOINs, also use raw GORM:

func (r *EntityRepository) FindByRelatedID(
	ctx context.Context,
	relatedID uint64,
) ([]model.EntityModel, error) {
	ctx, span := trace.Span(ctx, "EntityRepository.FindByRelatedID")
	defer span.End()

	var results []model.EntityModel
	err := r.DB.WithContext(ctx).
		Model(&model.EntityModel{}).
		Joins("JOIN related_table rt ON rt.entity_id = entities.id").
		Where("rt.related_id = ?", relatedID).
		Order("rt.id ASC").
		Find(&results).Error
	if err != nil {
		return nil, err
	}

	return results, nil
}

FindByID

func (r *EntityRepository) FindByID(ctx context.Context, id uint64) (model.EntityModel, error) {
	ctx, span := trace.Span(ctx, "EntityRepository.FindByID")
	defer span.End()

	entity, err := gorm.G[model.EntityModel](r.DB).
		Where("id = ?", id).
		Limit(1).
		First(ctx)
	if err != nil {
		if errors.Is(err, gorm.ErrRecordNotFound) {
			return model.EntityModel{}, brickserrs.ErrRecordNotFound
		}
		return model.EntityModel{}, err
	}
	return entity, nil
}

Create

func (r *EntityRepository) Create(ctx context.Context, entity model.EntityModel) (model.EntityModel, error) {
	ctx, span := trace.Span(ctx, "EntityRepository.Create")
	defer span.End()

	err := gorm.G[model.EntityModel](r.DB).Create(ctx, &entity)
	return entity, err
}

When the module defines a conflict error, map gorm.ErrDuplicatedKey:

func (r *EntityRepository) Create(ctx context.Context, entity model.EntityModel) (model.EntityModel, error) {
	ctx, span := trace.Span(ctx, "EntityRepository.Create")
	defer span.End()

	err := gorm.G[model.EntityModel](r.DB).Create(ctx, &entity)
	if err != nil {
		if errors.Is(err, gorm.ErrDuplicatedKey) {
			return model.EntityModel{}, errs.ErrEntityNameConflict
		}
		return model.EntityModel{}, err
	}
	return entity, nil
}

Update

For updates where all fields are non-zero, use the gorm.G Updates pattern:

func (r *EntityRepository) Update(ctx context.Context, entity model.EntityModel) (model.EntityModel, error) {
	ctx, span := trace.Span(ctx, "EntityRepository.Update")
	defer span.End()

	rowsAffected, err := gorm.G[model.EntityModel](r.DB).
		Where("id = ?", entity.ID).
		Updates(ctx, entity)
	if err != nil {
		return model.EntityModel{}, err
	}
	if rowsAffected == 0 {
		return model.EntityModel{}, brickserrs.ErrRecordNotFound
	}

	updated, err := gorm.G[model.EntityModel](r.DB).Where("id = ?", entity.ID).Limit(1).First(ctx)
	if err != nil {
		if errors.Is(err, gorm.ErrRecordNotFound) {
			return model.EntityModel{}, brickserrs.ErrRecordNotFound
		}
		return model.EntityModel{}, err
	}
	return updated, nil
}

Update (Zero-Value Fields)

GORM's Updates() skips zero values (false, 0, ""). When any updated field may be zero, use one of two patterns:

Option A — map[string]any (when fields are heterogeneous or sparse):

func (r *EntityRepository) Update(ctx context.Context, entity model.EntityModel) (model.EntityModel, error) {
	ctx, span := trace.Span(ctx, "EntityRepository.Update")
	defer span.End()

	updates := map[string]any{
		"name":      entity.Name,
		"is_active": entity.IsActive, // bool: would be skipped by plain Updates()
		"count":     entity.Count,    // int: would be skipped when 0
	}

	result := r.DB.WithContext(ctx).
		Model(&model.EntityModel{}).
		Where("id = ?", entity.ID).
		Updates(updates)
	if result.Error != nil {
		return model.EntityModel{}, result.Error
	}
	if result.RowsAffected == 0 {
		return model.EntityModel{}, brickserrs.ErrRecordNotFound
	}

	updated, err := gorm.G[model.EntityModel](r.DB).Where("id = ?", entity.ID).Limit(1).First(ctx)
	if err != nil {
		if errors.Is(err, gorm.ErrRecordNotFound) {
			return model.EntityModel{}, brickserrs.ErrRecordNotFound
		}
		return model.EntityModel{}, err
	}
	return updated, nil
}

Option B — Select(fields).Updates(&entity) (when updating a fixed set of columns):

result := r.DB.WithContext(ctx).
	Model(&model.EntityModel{}).
	Where("id = ?", entity.ID).
	Select("name", "slug", "is_active").
	Updates(&entity)

Single-Field Targeted Update

For methods that set one field by ID and return no model (e.g., MarkEmailConfirmed, SetTOTPEnabled), raw GORM is correct — this is intentional, not a deviation:

func (r *EntityRepository) MarkConfirmed(ctx context.Context, id uint64) error {
	ctx, span := trace.Span(ctx, "EntityRepository.MarkConfirmed")
	defer span.End()

	return r.DB.WithContext(ctx).Model(&model.EntityModel{}).
		Where("id = ?", id).
		Update("confirmed", true).Error
}

Delete

func (r *EntityRepository) Delete(ctx context.Context, id uint64) error {
	ctx, span := trace.Span(ctx, "EntityRepository.Delete")
	defer span.End()

	rowsAffected, err := gorm.G[model.EntityModel](r.DB).
		Where("id = ?", id).
		Delete(ctx)
	if err != nil {
		return err
	}
	if rowsAffected == 0 {
		return brickserrs.ErrRecordNotFound
	}
	return nil
}

Bulk Cleanup Delete

For DeleteExpired-style operations, zero rows deleted is not an error — discard rowsAffected:

func (r *EntityRepository) DeleteExpired(ctx context.Context) error {
	ctx, span := trace.Span(ctx, "EntityRepository.DeleteExpired")
	defer span.End()

	_, err := gorm.G[model.EntityModel](r.DB).
		Where("expires_at < ?", time.Now().UTC()).
		Delete(ctx)
	return err
}

Custom Query (by field)

func (r *EntityRepository) FindByName(ctx context.Context, name string) (model.EntityModel, error) {
	ctx, span := trace.Span(ctx, "EntityRepository.FindByName")
	defer span.End()

	entity, err := gorm.G[model.EntityModel](r.DB).
		Where("name = ?", name).
		Limit(1).
		First(ctx)
	if err != nil {
		if errors.Is(err, gorm.ErrRecordNotFound) {
			return model.EntityModel{}, brickserrs.ErrRecordNotFound
		}
		return model.EntityModel{}, err
	}
	return entity, nil
}

Transaction (relationship operations)

func (r *EntityRepository) AssignRelated(ctx context.Context, entityID uint64, relatedIDs []uint64) error {
	ctx, span := trace.Span(ctx, "EntityRepository.AssignRelated")
	defer span.End()

	tx := r.DB.Begin()

	_, err := gorm.G[model.EntityRelationModel](tx).
		Where("entity_id = ?", entityID).
		Delete(ctx)
	if err != nil {
		tx.Rollback()
		return err
	}

	var relations []model.EntityRelationModel
	for _, relatedID := range relatedIDs {
		relations = append(relations, model.EntityRelationModel{
			EntityID:  entityID,
			RelatedID: relatedID,
		})
	}

	err = gorm.G[model.EntityRelationModel](tx).CreateInBatches(ctx, &relations, len(relations))
	if err != nil {
		tx.Rollback()
		return err
	}

	if commitErr := tx.Commit().Error; commitErr != nil {
		return commitErr
	}

	return nil
}

Fx Wiring

Add to internal/modules/<module>/fx.go:

fx.Provide(
	fx.Annotate(
		repository.NewEntityRepository,
		fx.As(new(ports.EntityRepository)),
	),
),

Anti-Patterns (Do NOT Do These)

Missing .Limit(1) before .First() — BAD

// BAD: missing Limit(1) — always add it before First()
entity, err := gorm.G[model.EntityModel](r.DB).
    Where("id = ?", id).
    First(ctx)  // ← wrong
// GOOD
entity, err := gorm.G[model.EntityModel](r.DB).
    Where("id = ?", id).
    Limit(1).   // ← required
    First(ctx)

Wrong span variable name — BAD

// BAD: using 'span' instead of 'span'
ctx, span := trace.Span(ctx, "EntityRepository.FindByID")
defer span.End()
// GOOD
ctx, span := trace.Span(ctx, "EntityRepository.FindByID")
defer span.End()

Redundant method comments — BAD

// BAD: comment that just restates the method name
// FindByID finds an entity by ID.
func (r *EntityRepository) FindByID(ctx context.Context, id uint64) (model.EntityModel, error) {

// BAD: comment that just restates the constructor
// NewEntityRepository creates a new entity repository.
func NewEntityRepository(db *database.PingoDB) *EntityRepository {
// GOOD: no comment on self-evident methods
func (r *EntityRepository) FindByID(ctx context.Context, id uint64) (model.EntityModel, error) {

// GOOD: comment only when behavior needs explanation
// FindByPriority resolves a template using collection+category, then category, then global fallback.
func (r *AIPromptTemplateRepository) FindByPriority(...)

Positional constructor initialization — BAD

// BAD: positional — fragile if struct fields change
return &EntityRepository{db}
// GOOD: named field
return &EntityRepository{PingoDB: db}

Critical Rules

  1. No standalone functions: When a file contains a struct with methods, do not add standalone functions. Use private methods on the struct instead.
  2. Struct: Embed *database.PingoDB only.
  3. Constructor: MUST return pointer *EntityRepository and use named field init: {PingoDB: db}.
  4. Interface assertion: Add var _ ports.EntityRepository = (*EntityRepository)(nil) below the struct.
  5. Tracing: Every method MUST start with ctx, span:= trace.Span(ctx, "Repo.Method") and defer span.End(). Always name the variable span, never span.
  6. .Limit(1) before .First(): Every single-record lookup MUST have .Limit(1) immediately before .First(ctx). No exceptions.
  7. Not found: Return brickserrs.ErrRecordNotFound when errors.Is(err, gorm.ErrRecordNotFound).
  8. Delete rowsAffected: Check rowsAffected == 0 and return brickserrs.ErrRecordNotFound for targeted deletes. For bulk cleanup (DeleteExpired, etc.), discard rowsAffected — zero rows is not an error.
  9. Zero-value updates: Use map[string]any or Select(fields).Updates(&model) when any field may be a zero value (false, 0, ""). Plain Updates(entity) silently skips zero values.
  10. Complex queries: Use gorm.G[Model](r.DB) for simple queries. Fall back to r.DB.WithContext(ctx).Model(...) only when gorm.G is insufficient: dynamic multi-condition WHERE, JOINs, subqueries, or .Select() with raw SQL fragments.
  11. Module-specific errors: Prefer module-defined errors (e.g., errs.ErrEntityNotFound) over the generic brickserrs.ErrRecordNotFound when the module's errs/ package defines them. Map gorm.ErrDuplicatedKey to a module conflict error when one exists.
  12. No redundant method comments: Do not add comments above methods that merely restate the method name (e.g., // FindByID finds an entity by ID.). Only add comments where the logic or behavior is non-obvious.
  13. Comments on interfaces: Port interfaces MUST have a comprehensive doc comment on the type explaining its purpose and any non-obvious behavior.
  14. Validation: Run make lint and make nilaway after generation.

Workflow

  1. Create port interface in ports/<entity>_repository.go
  2. Create repository implementation in repository/<entity>_repository.go
  3. Add Fx wiring to module's fx.go
  4. Run make lint to verify
  5. Run make nilaway for static analysis

平台分布

Codex

38.12%
按下载量换算49

Claude

27.14%
按下载量换算35

Cursor

19.12%
按下载量换算25

Gemini CLI

10.42%
按下载量换算13

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

权限未标注

当前来源未能明确判断权限范围,默认进入异常复核队列。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills