Agent skill

Go Service Guide

by MaaEnd in MaaEnd/MaaEnd

MaaEnd go-service 编写指南。为 agent/go-service/ 下的 Go 代码提供架构、注册、命名、日志、注释等编码规范和模式参考。在编写、修改或审查 Go 自定义识别器、动作、EventSink,或需要了解 go-service 项目结构与 MaaFramework Go 集成方式时使用。

AGPL-3.0Auto-check passedMobile

Install Go Service Guide

skills CLI
$ npx skills add MaaEnd/MaaEnd --skill go-service-guide -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install MaaEnd/MaaEnd go-service-guide --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/MaaEnd/MaaEnd.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/go-service-guide .claude/skills/go-service-guide && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
go-service-guide
GitHub stars
4k
Token cost
~2.1k tokens
SKILL.md length
290 words
Files
1
Skills in repo
14
Repo updated
First seen
Licence
AGPL-3.0

At a glance

MaaEnd go-service 编写指南。为 agent/go-service/ 下的 Go 代码提供架构、注册、命名、日志、注释等编码规范和模式参考。在编写、修改或审查 Go 自定义识别器、动作、EventSink,或需要了解 go-service 项目结构与 MaaFramework Go 集成方式时使用。

  • Mobile work in your project
  • SKILL.md covers 架构定位, 目录结构, 注册机制 and Schema 维护, plus 12 more sections
  • Calls go

What it does

Go Service Guide is an agent skill from MaaEnd/MaaEnd. MaaEnd go-service 编写指南。为 agent/go-service/ 下的 Go 代码提供架构、注册、命名、日志、注释等编码规范和模式参考。在编写、修改或审查 Go 自定义识别器、动作、EventSink,或需要了解 go-service 项目结构与 MaaFramework Go 集成方式时使用。

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Mobile. The repository describes itself as: MaaEnd 终末地小助手:基于视觉 AI 的「明日方舟:终末地」自动化工具. The licence is AGPL-3.0.

When your agent uses it

  • Mobile work in your project

Example prompts

  • “/go-service-guide”

What it can do on your machine

Read from SKILL.md and the folder at commit 43eb28a. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • go

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • github.com
    • go.dev

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Go Service Guide loads about 2.1k tokens when it runs. Until then it costs about 44 tokens; SKILL.md has 290 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~44
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from MaaEnd/MaaEnd at commit 43eb28a, republished under its AGPL-3.0 licence (© MaaEnd). 290 words, ~2,115 tokens.

Download SKILL.mdSave it as .claude/skills/go-service-guide/SKILL.md (or your agent's skills folder).
name
go-service-guide
description
MaaEnd go-service 编写指南。为 agent/go-service/ 下的 Go 代码提供架构、注册、命名、日志、注释等编码规范和模式参考。在编写、修改或审查 Go 自定义识别器、动作、EventSink,或需要了解 go-service 项目结构与 MaaFramework Go 集成方式时使用。

MaaEnd Go Service 编写指南

架构定位

Go Service 仅处理 Pipeline 无法覆盖的复杂逻辑(图像算法、状态机、外部数据等)。禁止在 Go 中编写大规模业务流程——流程控制由 Pipeline JSON 负责。

所有坐标与图像以 720p (1280×720) 为基准。

目录结构

agent/go-service/
├── main.go                     # 入口:初始化、registerAll、启动 AgentServer
├── register.go                 # registerAll() 聚合各子包 Register()
├── logger.go                   # zerolog 初始化
├── pkg/                        # 公共工具包(详见 docs/zh_cn/developers/go-service-pkg.md)
│                               # recogtarget / boolexpr / ocrnum / jsonclean / pienv /
│                               # i18n / maafocus / resource / control / minicv / …
├── common/                     # 通用 Custom 组件(subtask、clearhitcount 等)
├── taskersink/                 # TaskerEventSink / ContextEventSink 实现
└── <business>/                 # 业务子包(resell、essencefilter、autofight 等)
    ├── register.go             # Register() —— 本包所有组件注册
    └── *.go                    # 按职责拆分的实现文件

注册机制

子包 Register()

每个子包必须有 register.go,只暴露一个 Register() 函数,在其中完成本包所有组件注册。

go
package mypkg

import maa "github.com/MaaXYZ/maa-framework-go/v4"

func Register() {
    maa.AgentServerRegisterCustomAction("MyAction", &MyAction{})
    maa.AgentServerRegisterCustomRecognition("MyRecognition", &MyRecognition{})
}

注册名称和参数必须与 Pipeline JSON 中 custom_action / custom_recognition 的 name、param 一致。

main 聚合

子包的 Register() 必须在 register.go 的 registerAll() 中调用:

go
func registerAll() {
    mypkg.Register()
    // ...
}

遗漏调用 = 组件不生效。

Schema 维护

新增、修改、重命名或删除 Custom 组件时同步维护 Pipeline Schema:

  • Action 使用 tools/schema/custom.action.schema.json,Recognition 使用 tools/schema/custom.recognition.schema.json。
  • 注册名有变化时,更新对应 Custom Schema 的 enum;重命名或删除前先更新 Pipeline 中的用法。
  • 参数有变化时,更新对应的参数 Schema。
  • 删除组件或参数时,一并清理不再使用的 Schema 规则和 $ref。
  • 复杂参数放入 tools/schema/components/ 并通过 $ref 引用。
  • 无参数或允许任意值透传时,不要创建空参数 Schema。
  • 不要修改 tools/schema/pipeline.schema.json;该文件已引用上述两个 Custom Schema。

编译期接口校验

所有注册类型必须在定义该类型的文件中包含编译期校验,不要集中放在 register.go:

go
var _ maa.CustomActionRunner      = &MyAction{}
var _ maa.CustomRecognitionRunner = &MyRecognition{}
var _ maa.TaskerEventSink         = &MySink{}
var _ maa.ContextEventSink        = &MySink{}

句柄生命周期(maa-framework-go v4.0.0-beta.19 起)

回调(Custom 的 Run、EventSink 的各方法)里拿到的 *maa.Context、*maa.Tasker、*maa.Controller、*maa.Resource 都是借用视图,必须遵守:

  • 只在本次回调内使用。 回调返回后 ctx.GetTasker() / ctx.Clone() 返回 nil,其余方法返回 maa.ErrClosed。禁止存进包级变量或跨回调存活的结构体,禁止交给回调返回后仍在运行的 goroutine。
  • 同一回调内 controller / resource 只取一次,取到后往下传。 Tasker.GetController() / GetResource() 每调用一次,agent 侧就会销毁上一次返回的对象;继续使用旧对象是释放后使用,表现为 go-service 随机崩溃。辅助函数需要 controller 时接收 *maa.Controller 参数,不要自己再从 ctx 取。
  • PostXxx() 返回的 Job 紧接着 .Wait()。 Job 绑定在取它的那个 controller 上,不要隔着另一次 GetController() 再等。
  • 取到后先判空。 与客户端断连等情况下 GetTasker() / GetController() / GetResource() 返回 nil;绑定的回调里没有 recover,空指针 panic 会直接结束 go-service 进程。
  • 不要对借用视图调用 Destroy(),也不要把它们传给 BindResource / BindController,二者都返回 maa.ErrBorrowed。
  • 判断控制器类型用 pienv.ControllerType() / pienv.ControllerName()。 不要为此去取 controller 调 GetInfo();GetInfo() 只在需要窗口句柄等 PI 没有的信息时使用。
  • 识别未命中返回 nil, false。 返回非 nil 的 result 时,即使第二个返回值为 false,Box 与 Detail 也会交给 MaaFramework 写进识别详情;只有确实要带诊断信息时才这么做。
go
// ❌ 辅助函数里又取了一次,Run 手里的 ctrl 随即失效
func (a *MyAction) Run(ctx *maa.Context, arg *maa.CustomActionArg) bool {
    ctrl := ctx.GetTasker().GetController()
    img := capture(ctx)         // 内部再次 ctx.GetTasker().GetController()
    ctrl.PostClick(x, y).Wait() // 释放后使用
    return img != nil
}

// ✅ 入口取一次并判空,往下传
func (a *MyAction) Run(ctx *maa.Context, arg *maa.CustomActionArg) bool {
    tasker := ctx.GetTasker()
    if tasker == nil {
        return false
    }
    ctrl := tasker.GetController()
    if ctrl == nil {
        return false
    }
    img := capture(ctrl)
    ctrl.PostClick(x, y).Wait()
    return img != nil
}

ctx.RunTask 等触发的嵌套 Custom 回调有各自独立的 ctx,不受外层持有的 controller 影响,反之亦然。

文件管理

  • 一个 Custom 组件的实现尽量集中在单个文件。
  • 同包内可按职责拆分多个 .go(register.go + 功能文件),保持单文件行数可控。
  • 参数结构体(xxxParam)放在实现文件中,紧跟类型定义。

命名

  • 包名:简短、小写、单词优先(Go 包命名惯例);包名已表达语义时不加冗余前缀。
  • 类型/变量:清晰驼峰;导出名能表意,未导出名保持简短。

日志(zerolog)

统一 zerolog,禁止 log.Printf / log.Println。

go
log.Info().
    Str("component", "MyComponent").
    Str("step", "Step1").
    Msg("short description")

log.Error().
    Err(err).
    Str("component", "MyComponent").
    Msg("what failed")
  • 上下文(组件名、步骤、场景)用链式字段,禁止拼进 Msg。
  • 错误、参数、识别结果一律用链式字段(.Err(err)、.Int("x", x))。

注释

  • 导出符号:必须添加注释,以符号名开头(便于 go doc),说明用途、参数、返回值。
  • 未导出但复杂的逻辑:初始化、多分支错误处理、算法步骤等应有简要注释。
  • 判断标准:读者能否在不读实现的情况下理解何时/为何被调用。

CustomAction 模板

go
package mypkg

import (
    "encoding/json"

    maa "github.com/MaaXYZ/maa-framework-go/v4"
    "github.com/rs/zerolog/log"
)

var _ maa.CustomActionRunner = &MyAction{}

type myActionParam struct {
    Target string `json:"target"`
}

// MyAction does X when Pipeline calls custom_action "MyAction".
type MyAction struct{}

func (a *MyAction) Run(ctx *maa.Context, arg *maa.CustomActionArg) bool {
    var params myActionParam
    if err := json.Unmarshal([]byte(arg.CustomActionParam), &params); err != nil {
        log.Error().
            Err(err).
            Str("component", "MyAction").
            Msg("failed to parse params")
        return false
    }

    // ... 业务逻辑 ...

    return true
}

CustomRecognition 模板

go
package mypkg

import (
    "encoding/json"

    maa "github.com/MaaXYZ/maa-framework-go/v4"
    "github.com/rs/zerolog/log"
)

var _ maa.CustomRecognitionRunner = &MyRecognition{}

type myRecognitionParam struct {
    Threshold float64 `json:"threshold"`
}

// MyRecognition performs X recognition.
type MyRecognition struct{}

func (r *MyRecognition) Run(ctx *maa.Context, arg *maa.CustomRecognitionArg) (*maa.CustomRecognitionResult, bool) {
    var params myRecognitionParam
    if err := json.Unmarshal([]byte(arg.CustomRecognitionParam), &params); err != nil {
        log.Error().
            Err(err).
            Str("component", "MyRecognition").
            Msg("failed to parse params")
        return nil, false
    }

    // ... 识别逻辑,使用 arg.Img ...

    matched := true // 判断是否命中
    if !matched {
        return nil, false
    }

    return &maa.CustomRecognitionResult{
        Box:    arg.Roi,
        Detail: "...",
    }, true
}

EventSink 模板

go
package mypkg

import maa "github.com/MaaXYZ/maa-framework-go/v4"

var _ maa.TaskerEventSink = &MySink{}

// MySink does X on task lifecycle events.
type MySink struct{}

func (s *MySink) OnTaskerTask(tasker *maa.Tasker, event maa.EventStatus, detail maa.TaskerTaskDetail) {
    if event != maa.EventStatusStarting {
        return
    }
    // ...
}

如需同时监听 Context 事件,实现 maa.ContextEventSink 并通过 maa.AgentServerAddContextSink 注册。未使用的回调方法写空实现。

错误处理

  • 错误合理返回或记录,便于上层分支处理。
  • 避免静默吞掉错误。

审查清单

  • 注册名与 Pipeline name / param 一致
  • Register() 已在 registerAll() 中调用
  • Action 注册名变化已同步到 tools/schema/custom.action.schema.json 的 enum
  • Recognition 注册名变化已同步到 tools/schema/custom.recognition.schema.json 的 enum
  • 参数变化已同步到上述文件或 tools/schema/components/,删除内容已清理旧规则和 $ref
  • 编译期接口校验在类型定义文件中
  • 回调内 controller / resource 只取一次并已判空,辅助函数通过参数接收,不自行再取
  • 没有把 ctx / tasker / controller / resource 留到回调返回之后使用
  • 识别未命中返回 nil, false
  • zerolog 链式写法,无 log.Printf,上下文不拼进 Msg
  • 导出符号有注释
  • 无大规模流程代码——流程由 Pipeline 驱动
  • 坐标/图像基于 720p
  • 无多余 time.Sleep(有明确用途注释的除外)
  • 重复逻辑考虑抽取为共用函数或子包

参考

  • 项目整体规范:根目录 AGENTS.md
  • 注册示例:agent/go-service/register.go + 各子包 register.go
  • Custom 节点文档:docs/zh_cn/developers/custom.md
  • 公共工具包:docs/zh_cn/developers/go-service-pkg.md(pkg/recogtarget、boolexpr、ocrnum、i18n 等)
  • Pipeline 协议:MaaFramework PipelineProtocol
  • Go binding:vendor/github.com/MaaXYZ/maa-framework-go/v4/
  • Go binding beta.19 迁移指南:v4.0.0-beta.19.md

© MaaEnd, AGPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/go-service-guide of MaaEnd/MaaEnd.

Open the folder on GitHubat commit 43eb28a

Compare with similar skills

Go Service Guide next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Go Service Guide compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Go Service Guide this skillMaaEnd/MaaEnd4k—~2.1kAutomated safety check: PassAGPL-3.0
React Native Best Practicesvercel-labs/openreview1.7k17 repos~1.1kAutomated safety check: PassMIT
Swiftui Protwostraws/SwiftUI-Agent-Skill5.2k2 repos~1.5kAutomated safety check: PassMIT
Kortix Brandkortix-ai/suna20k—~4kAutomated safety check: PassCustom licence
Ip As LogoKartikLabhshetwar/better-shot2.4k1 repos~4.3kAutomated safety check: PassMIT
Compose Multiplatform Patternsmonta-app/ocpp-emulator1805 repos~2kAutomated safety check: PassApache-2.0

Similar skills

  • React Native Best Practices

    vercel-labs/openreview

    Official

    A prioritized rule set for React Native and Expo apps covering list performance, animation, navigation, UI patterns, state, rendering, monorepos and configuration.

    1.7k GitHub starsUsed in 17 repos~1.1k tokens
    MobileAuto-check passed
  • Swiftui Pro

    twostraws/SwiftUI-Agent-Skill

    Comprehensively reviews SwiftUI code for best practices on modern APIs, maintainability, and performance.

    5.2k GitHub starsUsed in 2 repos~1.5k tokens
    MobileAuto-check passed
  • Kortix Brand

    kortix-ai/suna

    Load FIRST for anything that carries the Kortix look or voice: product or mobile UI, copy of any kind, decks, social, images, email, CLI output, anything with the logo, and reviews of these.

    20k GitHub stars~4k tokensUpdated today
    MobileAuto-check passed
  • Ip As Logo

    KartikLabhshetwar/better-shot

    Generate extremely simple, cute, personified square character images with rounded heavy forms, two purposeful character colors, one solid background color, and a dominant lower-corner composition.

    2.4k GitHub starsUsed in 1 repo~4.3k tokens
    MobileAuto-check passed
  • Compose Multiplatform Patterns

    monta-app/ocpp-emulator

    Compose Multiplatform and Jetpack Compose patterns for KMP projects — state management, navigation, theming, performance, and platform-specific UI.

    180 GitHub starsUsed in 5 repos~2k tokens
    MobileAuto-check passed
  • Aso Appstore Screenshots

    adamlyttleapps/claude-skill-aso-appstore-screenshots

    Generate high-converting App Store screenshots by analyzing your app's codebase, discovering core benefits, and creating ASO-optimized screenshot images using Nano Banana Pro.

    1.8k GitHub starsUsed in 1 repo~9.6k tokens
    MobileAuto-check passed

More from MaaEnd/MaaEnd

All 14 skills in this repo
  • Maa Logging

    MaaEnd/MaaEnd

    MaaFramework 日志宏用法指南,适用于 MaaEnd cpp-algo。Use when writing logging code, using LogInfo/LogError/LogWarn/LogDebug/LogTrace, outputting containers or custom types to logs, or when the user asks about…

    4k GitHub stars~807 tokensUpdated yesterday
    Auto-check passed
  • Maaend Test Image

    MaaEnd/MaaEnd

    为 MaaEnd 添加、导入或补充节点识别测试截图,并按仓库约定脱敏图片、放入 tests/MaaEndTestset、维护 tests//test.json 和运行 pnpm check/pnpm test 验证。用户提到“添加测试图片/截图”“把截图加入 ADB 或 Win32 测试集”“给节点补正例或反例”“更新 hits/box”“UID…

    4k GitHub stars~1.3k tokensUpdated yesterday
    Auto-check passed
  • Meojson

    MaaEnd/MaaEnd

    Guide for using the meojson C++ JSON library in MaaEnd cpp-algo.

    4k GitHub stars~2.1k tokensUpdated yesterday
    Auto-check passed
  • 新增或改写 MaaEnd 的 AutoCollect 自动采集路线说明。默认包含路线文件创建、AutoCollect 主入口接线、任务选项注册和多语言文案补充。适用于“参考现有 AutoCollect 路线新建一条采集线”“给定传送点与路径点位生成 AutoCollectRouteX.json 并注册到任务中”“用户已经写好路线文件,只需要补注册接口”等场景。注意:本 skill 仅适用于参考…

    4k GitHub stars~3.2k tokensUpdated yesterday
    Auto-check passed
  • 仅分析 AutoStockStapleMain 的 MaaEnd 日志。用于还原该任务实际购买了什么、购买所对应的证据、逐步剩余账单(券/账单)数值时间线,以及在 pipeline 或 go-service 中应当加日志/埋点的位置。适用于用户询问 AutoStockStapleMain、AutoStockStaple、武陵/四号谷地的稳定需求物资购买,或该任务内账单数值变化原因等场景。

    4k GitHub stars~2.8k tokensUpdated yesterday
    Auto-check passed
  • Cpp Algo Style

    MaaEnd/MaaEnd

    MaaEnd cpp-algo C++ 编码风格与工程规范指南。参考 MaaFramework 的优秀实践,规范命名、头文件、公共工具、错误处理、日志、CMake 等方面。在编写、修改或审查 agent/cpp-algo/ 下的 C++ 代码时使用。

    4k GitHub stars~2.3k tokensUpdated yesterday
    Auto-check passed

Categories

Questions about Go Service Guide

What does Go Service Guide do?

MaaEnd go-service 编写指南。为 agent/go-service/ 下的 Go 代码提供架构、注册、命名、日志、注释等编码规范和模式参考。在编写、修改或审查 Go 自定义识别器、动作、EventSink,或需要了解 go-service 项目结构与 MaaFramework Go 集成方式时使用。. Go Service Guide is an agent skill from MaaEnd/MaaEnd.

When should I use Go Service Guide?

Go Service Guide fits situations like: mobile work in your project.

How do I install Go Service Guide in Claude Code?

Run `npx skills add MaaEnd/MaaEnd --skill go-service-guide -a claude-code`. Or copy the skill folder (.agents/skills/go-service-guide in MaaEnd/MaaEnd) into .claude/skills/go-service-guide in your project. Claude Code loads it when a task matches its description.

How do I install Go Service Guide in Codex?

Run `npx skills add MaaEnd/MaaEnd --skill go-service-guide -a codex`. Or copy the skill folder (.agents/skills/go-service-guide in MaaEnd/MaaEnd) into .agents/skills/go-service-guide in your project. Codex loads it when a task matches its description.

Can I use Go Service Guide in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add MaaEnd/MaaEnd --skill go-service-guide -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/go-service-guide, .gemini/skills/go-service-guide, .github/skills/go-service-guide and .opencode/skills/go-service-guide in your project.

What does Go Service Guide need to run?

Going by SKILL.md and its folder, Go Service Guide needs the command-line tools its instructions call (go).

Does Go Service Guide access the network?

SKILL.md names 2 domains. As links in the text: github.com and go.dev. This is read from the text; nothing was executed.

Is Go Service Guide safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Go Service Guide use?

Go Service Guide is published under the AGPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Go Service Guide use?

About 2.1k tokens (SKILL.md is roughly 8.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Go Service Guide?

Skills that share tags, products or a category with Go Service Guide: React Native Best Practices (vercel-labs/openreview, 1.7k stars), Swiftui Pro (twostraws/SwiftUI-Agent-Skill, 5.2k stars), Kortix Brand (kortix-ai/suna, 20k stars) and Ip As Logo (KartikLabhshetwar/better-shot, 2.4k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Go Service Guide?

MaaEnd (a GitHub organization) maintains it in MaaEnd/MaaEnd, which has 3,995 GitHub stars. The repository holds 14 skills in this directory. The repository was last updated on October 8, 2026.

Source: MaaEnd/MaaEnd on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.