Math content

From 2017YANR02/cuberoot.me · View interactive version

Math content is an AI agent skill from the GitHub repository 2017YANR02/cuberoot.me. Use when adding 数学内容 under /math: a new section in a long-form page such as /math/group or /math/god, or a new top-level math topic page. Covers bilingual sections, lazy loading, slug routing, and interactive SVG in the active Next client.

How to use this skill

Skill file

/math/* 加内容

全在 client(core/packages/client/app/[lang]/math/,Next 16 App Router,文件即路由)。退役的 Vite client 不碰。Hub 在 math/page.tsx(CARDS 数组 → /math 上的卡)。已有子页:group(魔方与群论,62 节 slug 路由长文)、god、demigod、unit-distance,各自 <topic>/page.tsx('use client') + co-located <topic>.css + _components/。

两种加法,先判断走哪条:

Mode A — 给已有的长篇"书"页加一节(默认走这条:/math/group 加 §N)

/math/group 是 slug 路由的多节长文:[slug]/page.tsx 只 re-export ../page 的 default;page.tsx 用 SlugContext + <GTSec>(按 slug 门控,只渲染当前节)。单节出错不波及全站。加一节:

  1. 新建 _components/sections/<Name>.tsx:
  1. 接线 page.tsx(4 处):
  1. slug 走 [slug] 动态路由,无需 generateStaticParams。

Mode B — 加一个全新 /math 顶层主题页(像 /math/god)

  1. 新建 app/[lang]/math/<topic>/page.tsx('use client' + useDocumentTitle + useTranslation 取 lang)+ co-located <topic>.css(+ 可选 _components/)。
  2. 改 math/page.tsx 的 CARDS 加一张卡(to / Icon(lucide) / zh{title,desc} / en{title,desc})。
  3. 颜色走全局 theme tokens(调 theme-tokens skill),别硬码灰阶。

硬约束(每节/每页必守)

大批量扩充(派 agent 并行)

一次加很多节时:page.tsx 是单个大文件(>15k 行),禁让多 agent 同改 page.tsx(必撞)。让每个 agent 只写自己那一个 _components/sections/<Name>.tsx(文件名唯一 → 零冲突,不碰 CSS / page.tsx),最后由你一次性人工接线(import/TOC/themes)。给 agent 的合同 = 上面全部硬约束 + 精确文件绝对路径 + export 名 + 事实核查过的 spec。推荐流水线:研究核查 → 撰写(可用 sonnet) → 对抗式复核(数学+编译+交互+双语,opus),别信子 agent 自报"通过",收尾自己跑权威检查。详见 memory project_math_group_expansion。

写完检查(必做,green typecheck ≠ 做好)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.