Agent skill

Model Field Accessor First

by yyw-code in yyw-code/MallBase

MallBase ThinkPHP 模型字段访问器与素材回显规则;在 Model 字段读写、访问器、修改器、with 关联、素材 ID 回显或 Service 字段组装优化时使用。

MITAuto-check passed

Install Model Field Accessor First

skills CLI
$ npx skills add yyw-code/MallBase --skill model-field-accessor-first -a claude-code

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

GitHub CLI
$ gh skill install yyw-code/MallBase model-field-accessor-first --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/yyw-code/MallBase.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.codex/skills/thinkPHP/model-field-accessor-first .claude/skills/model-field-accessor-first && 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
model-field-accessor-first
GitHub stars
106
Token cost
~504 tokens
SKILL.md length
169 words
Files
1
Skills in repo
12
Repo updated
First seen
Licence
MIT

At a glance

MallBase ThinkPHP 模型字段访问器与素材回显规则;在 Model 字段读写、访问器、修改器、with 关联、素材 ID 回显或 Service 字段组装优化时使用。

  • Works in 10 steps: 正式模型字段的结构语义优先放在 Model 中处理,例如关联、枚举文案、JSON… → 正式模型字段的写入,优先依赖 Model 类型转换、修改器和… → Service 允许做保存前业务归一化,例如字段裁剪、结构标准化、业务校验。 → …
  • SKILL.md covers 适用范围, 强制规则, 推荐做法 and 素材字段判定, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Model Field Accessor First is an agent skill from yyw-code/MallBase. MallBase ThinkPHP 模型字段访问器与素材回显规则;在 Model 字段读写、访问器、修改器、with 关联、素材 ID 回显或 Service 字段组装优化时使用。

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

It works with PHP. The repository describes itself as: MallBase 是一个基于 PHP 的商城型业务基础框架,围绕 用户、商品、订单、权限 四个最核心的商业模块,提供一套清晰、稳定、可扩展的业务结构基线。 它不是一个功能齐全的电商系统,也不是通用 Web 框架,而是一个专注于“商城核心模型”的业务底座,用于快速构建和演进各类商业应用。 The licence is MIT.

Example prompts

  • “/model-field-accessor-first”

Workflow steps

10 steps, taken from the first numbered list in SKILL.md.

  1. 正式模型字段的结构语义优先放在 Model 中处理,例如关联、枚举文案、JSON 归一化、修改器。
  2. 正式模型字段的写入,优先依赖 Model 类型转换、修改器和 $model->save()。
  3. Service 允许做保存前业务归一化,例如字段裁剪、结构标准化、业务校验。
  4. 简单展示型关联优先使用模型关联 + with(),避免重复手写 ids -> map -> foreach。
  5. JSON 字段如果定义了获取器,必须兼容 think\model\type\Json 对象输入,不能假设传入值一定是数组。
  6. 路径/URL 字段可以在模型访问器中补充 *_full_url。
  7. 素材 ID 字段禁止在模型访问器中查素材表或调用只能处理路径的 buildUploadUrl() 伪装成 URL 回显。
  8. 素材 ID 的 *_full_url 回显必须在 Service 层或专用回显服务中批量解析,避免模型访问器隐式 N+1。
  9. 关联字段参与筛选、排序、聚合时,使用 join、exists 或明确的关联 ID 查询,不依赖 with()。
  10. 禁止在 Controller / Service / Model 中使用 var_dump、dump、echo、die 这类会污染接口响应的调试输出。

What it can do on your machine

Read from SKILL.md and the folder at commit 3f10589. 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

    No scripts in the folder and no shell commands in SKILL.md.

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

  • Network

    No URLs in SKILL.md.

    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

Model Field Accessor First loads about 504 tokens when it runs. Until then it costs about 29 tokens; SKILL.md has 169 words of instructions outside code blocks.

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

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 yyw-code/MallBase at commit 3f10589, republished under its MIT licence (© yyw-code). 169 words, ~504 tokens.

Download SKILL.mdSave it as .claude/skills/model-field-accessor-first/SKILL.md (or your agent's skills folder).
name
model-field-accessor-first
description
MallBase ThinkPHP 模型字段访问器与素材回显规则;在 Model 字段读写、访问器、修改器、with 关联、素材 ID 回显或 Service 字段组装优化时使用。

ThinkPHP 规则:模型语义优先,素材回显批量处理

适用范围

  • backend/app/*/model/**
  • backend/app/*/service/**
  • 重点字段:JSON 字段、路径/URL 字段、素材 ID 字段、模型关联、需要补充 *_full_url 的返回字段

强制规则

  1. 正式模型字段的结构语义优先放在 Model 中处理,例如关联、枚举文案、JSON 归一化、修改器。
  2. 正式模型字段的写入,优先依赖 Model 类型转换、修改器和 $model->save()。
  3. Service 允许做保存前业务归一化,例如字段裁剪、结构标准化、业务校验。
  4. 简单展示型关联优先使用模型关联 + with(),避免重复手写 ids -> map -> foreach。
  5. JSON 字段如果定义了获取器,必须兼容 think\model\type\Json 对象输入,不能假设传入值一定是数组。
  6. 路径/URL 字段可以在模型访问器中补充 *_full_url。
  7. 素材 ID 字段禁止在模型访问器中查素材表或调用只能处理路径的 buildUploadUrl() 伪装成 URL 回显。
  8. 素材 ID 的 *_full_url 回显必须在 Service 层或专用回显服务中批量解析,避免模型访问器隐式 N+1。
  9. 关联字段参与筛选、排序、聚合时,使用 join、exists 或明确的关联 ID 查询,不依赖 with()。
  10. 禁止在 Controller / Service / Model 中使用 var_dump、dump、echo、die 这类会污染接口响应的调试输出。

推荐做法

  1. 正式字段先在 Model 中声明 $json、$jsonAssoc、$append。
  2. 一对一、一对多等简单展示关系先定义模型关联,读取时优先 with()。
  3. 读取路径/URL 字段时,可以通过 get*Attr() 补充展示字段。
  4. 读取素材 ID 字段时,用 AssetHydrator 或等价批量解析工具补充 *_full_url。
  5. 保存时让 Service 只做结构归一化,再交给 Model 持久化。
  6. 若 Swoole 常驻进程未刷新字段定义,优先重启服务,不在业务代码里加绕行逻辑。

素材字段判定

  • 字段类型或注释是素材 ID,例如 bigint unsigned COMMENT '头像素材ID':不要在模型访问器里拼 URL。
  • 字段类型是路径字符串,例如 varchar(255) COMMENT '头像' 且存 /static/...、/uploads/...、https://...:可以使用 buildUploadUrl()。
  • 同一个接口返回多条记录时,素材 URL 必须批量解析,不允许每条记录独立查素材。

反例

  • 在 User::getAvatarFullUrlAttr() 里把素材 ID 1 传给 buildUploadUrl('1')。
  • 在模型访问器里通过素材 ID 查询 upload_asset 表。
  • Service 中为简单关联展示手写多层 array_column -> whereIn -> map -> foreach,而模型已有清晰关系可用。
  • 只包一层 app()->make() 且没有测试替身价值的私有方法。
  • 在 getSpecMetaAttr() 里直接 var_dump($value)

自检清单

  • 简单展示型关联是否已优先使用 with()。
  • 关联字段参与查询条件时,是否在查询构建方法中处理。
  • 素材 ID 字段是否避免了模型访问器隐式查询。
  • 素材 URL 是否通过批量回显补充。
  • 路径/URL 字段的访问器是否与 schema 匹配。
  • JSON 字段获取器是否兼容 think\model\type\Json。
  • 展示增强是否只追加字段,不覆盖原始存储值。
  • Service 中是否还存在无收益薄封装。
  • 接口链路中是否已清除调试输出。

© yyw-code, MIT. 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 .codex/skills/thinkPHP/model-field-accessor-first of yyw-code/MallBase.

Open the folder on GitHubat commit 3f10589

Compare with similar skills

Model Field Accessor First 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.

Model Field Accessor First compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Model Field Accessor First this skillyyw-code/MallBase106—~504Automated safety check: PassMIT
Configuring Horizoncoollabsio/coolify63k4 repos~898Automated safety check: PassMIT
Tailwindcss Developmentanonaddy/anonaddy4.9k10 repos~865Automated safety check: PassMIT
Fortify Developmentcoollabsio/coolify63k4 repos~1.9kAutomated safety check: PassMIT
MCP Developmentcoollabsio/coolify63k1 repos~949Automated safety check: PassMIT
WooCommerce Code Reviewwoocommerce/woocommerce11k3 repos~1.1kAutomated safety check: PassCustom licence

Similar skills

  • Configuring Horizon

    coollabsio/coolify

    A skill your agent uses whenever the user mentions Horizon by name in a Laravel context.

    63k GitHub starsUsed in 4 repos~898 tokens
    Backend & APIsAuto-check passed
  • Tailwindcss Development

    anonaddy/anonaddy

    Always invoke when the user's message includes 'tailwind' in any form.

    4.9k GitHub starsUsed in 10 repos~865 tokens
    Frontend & DesignAuto-check passed
  • Fortify Development

    coollabsio/coolify

    ACTIVATE when the user works on authentication in Laravel. An agent skill from coollabsio/coolify.

    63k GitHub starsUsed in 4 repos~1.9k tokens
    Backend & APIsAuto-check passed
  • MCP Development

    coollabsio/coolify

    A skill your agent uses for Laravel MCP development. An agent skill from coollabsio/coolify.

    63k GitHub starsUsed in 1 repo~949 tokens
    Frontend & DesignAuto-check passed
  • WooCommerce Code Review

    woocommerce/woocommerce

    Reviews WooCommerce code changes against the project's standards, flagging backend PHP architecture, naming, documentation, data integrity and testing violations.

    11k GitHub starsUsed in 3 repos~1.1k tokens
    DevelopmentAuto-check passed
  • Sync Translations

    symfony/symfony

    Synchronize translation catalogs across maintained Symfony branches: find messages that newer branches added to the English catalogs but that are still missing from the oldest maintained branch…

    31k GitHub stars~1.9k tokensUpdated today
    Writing & ContentAuto-check passed

More from yyw-code/MallBase

All 12 skills in this repo
  • MallBase 支付与退款回调安全规则;修改 backend/route/notify.php、PayNotifyController、NotifyService、WechatPaymentResultService、mbpaymentlog,或处理微信/其它渠道 webhook 的验签、解密、防重放、金额校验、幂等、事务与 HTTP 应答时使用。

    106 GitHub stars~495 tokensUpdated 2 mo ago
    Auto-check passed
  • Route Permission System

    yyw-code/MallBase

    MallBase ThinkPHP 后台路由与权限元数据规则;新增或调整 backend/route/api/admin 路由、System 权限码、菜单元数据、/:id 路径参数、共享 permission 或 sync:permissions 同步时使用。

    106 GitHub stars~499 tokensUpdated 2 mo ago
    Auto-check passed
  • Upload Component First

    yyw-code/MallBase

    MallBase Vben Admin 上传组件与字段契约规则;实现图片、视频或文件上传,以及处理 FileInfo 回填和提交值时使用。

    106 GitHub stars~553 tokensUpdated 2 mo ago
    Auto-check passed
  • Architecture Layering

    yyw-code/MallBase

    MallBase ThinkPHP 后端分层、Swoole Service 无状态与 IDE 泛型规则;开发或重构 backend/app 下的 Controller、Service、Model,调整 BaseController/BaseService、service()/model() 调用、构造注入或协程安全状态时使用。

    106 GitHub stars~391 tokensUpdated 2 mo ago
    Auto-check passed
  • E2E Webantd Realapi

    yyw-code/MallBase

    MallBase Vben Admin 局部格式化与真实后端 E2E 收口规则;修改、测试或回归 web-antd 代码时使用。

    106 GitHub stars~308 tokensUpdated 2 mo ago
    Auto-check passed
  • List Query Sync

    yyw-code/MallBase

    MallBase ThinkPHP 列表查询与分页返回规则;实现或调整 Service 的 buildListQuery、分页 list/total、动态筛选、关联查询、统计、导出或 compact('total', 'list') 返回时使用。

    106 GitHub stars~395 tokensUpdated 2 mo ago
    Auto-check passed

Works with

Questions about Model Field Accessor First

What does Model Field Accessor First do?

MallBase ThinkPHP 模型字段访问器与素材回显规则;在 Model 字段读写、访问器、修改器、with 关联、素材 ID 回显或 Service 字段组装优化时使用。. Model Field Accessor First is an agent skill from yyw-code/MallBase.

How do I install Model Field Accessor First in Claude Code?

Run `npx skills add yyw-code/MallBase --skill model-field-accessor-first -a claude-code`. Or copy the skill folder (.codex/skills/thinkPHP/model-field-accessor-first in yyw-code/MallBase) into .claude/skills/model-field-accessor-first in your project. Claude Code loads it when a task matches its description.

How do I install Model Field Accessor First in Codex?

Run `npx skills add yyw-code/MallBase --skill model-field-accessor-first -a codex`. Or copy the skill folder (.codex/skills/thinkPHP/model-field-accessor-first in yyw-code/MallBase) into .agents/skills/model-field-accessor-first in your project. Codex loads it when a task matches its description.

Can I use Model Field Accessor First 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 yyw-code/MallBase --skill model-field-accessor-first -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/model-field-accessor-first, .gemini/skills/model-field-accessor-first, .github/skills/model-field-accessor-first and .opencode/skills/model-field-accessor-first in your project.

What does Model Field Accessor First need to run?

SKILL.md names no scripts, command-line tools or credentials: Model Field Accessor First is instructions for the agent only.

Does Model Field Accessor First access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Model Field Accessor First 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 Model Field Accessor First use?

Model Field Accessor First is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Model Field Accessor First use?

About 504 tokens (SKILL.md is roughly 2k 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 Model Field Accessor First?

Skills that share tags, products or a category with Model Field Accessor First: Configuring Horizon (coollabsio/coolify, 63k stars), Tailwindcss Development (anonaddy/anonaddy, 4.9k stars), Fortify Development (coollabsio/coolify, 63k stars) and MCP Development (coollabsio/coolify, 63k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Model Field Accessor First?

yyw-code (a GitHub user) maintains it in yyw-code/MallBase, which has 106 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on August 3, 2026.

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