Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add guyulong/cn-agent-skills --skill canvas-optimizegit clone --depth 1 https://github.com/guyulong/cn-agent-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/guyulong/cn-agent-skills/canvas-optimize)<a href="https://agentmods.dev/skills/guyulong/cn-agent-skills/canvas-optimize"><img src="https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/canvas-optimize/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/guyulong/cn-agent-skills/canvas-optimize"><img src="https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/canvas-optimize.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00010 | $0.01045 |
| Opus 5.5 | $0.00004 | $0.00418 |
| Sonnet 5.5 | $0.00002 | $0.00209 |
| Haiku 4.5 | $0.00001 | $0.00104 |
Grade A, and why
canvas-optimize scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 168 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Canvas渲染优化
使用场景
优化HTML5 Canvas的渲染性能。
核心优化技巧
1. 脏矩形渲染
只重绘发生变化的区域,而非整个画布。
class DirtyRectRenderer {
constructor(canvas) {
this.canvas = canvas;
this.ctx = canvas.getContext('2d');
this.dirtyRects = [];
}
markDirty(x, y, w, h) {
this.dirtyRects.push({ x, y, w, h });
}
render(drawFunc) {
if (this.dirtyRects.length === 0) return;
// 合并脏矩形
const bounds = this.mergeDirtyRects();
// 清除脏区域
this.ctx.clearRect(bounds.x, bounds.y, bounds.w, bounds.h);
// 只重绘脏区域
this.ctx.save();
this.ctx.beginPath();
this.ctx.rect(bounds.x, bounds.y, bounds.w, bounds.h);
this.ctx.clip();
drawFunc();
this.ctx.restore();
this.dirtyRects = [];
}
mergeDirtyRects() {
let minX = Infinity, minY = Infinity;
let maxX = -Infinity, maxY = -Infinity;
for (const rect of this.dirtyRects) {
minX = Math.min(minX, rect.x);
minY = Math.min(minY, rect.y);
maxX = Math.max(maxX, rect.x + rect.w);
maxY = Math.max(maxY, rect.y + rect.h);
}
return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };
}
}
2. 离屏Canvas
将静态内容渲染到离屏Canvas,然后绘制到主Canvas。
// 创建离屏Canvas
const offscreen = document.createElement('canvas');
offscreen.width = 800;
offscreen.height = 600;
const offCtx = offscreen.getContext('2d');
// 在离屏Canvas上绘制静态内容
function drawStaticContent() {
offCtx.fillStyle = '#f0f0f0';
offCtx.fillRect(0, 0, 800, 600);
// ... 其他静态内容
}
// 主循环中直接绘制离屏Canvas
function render() {
ctx.drawImage(offscreen, 0, 0);
// ... 绘制动态内容
}
3. 对象池
避免频繁创建和销毁对象。
class Pool {
constructor(createFn, resetFn, size = 100) {
this.createFn = createFn;
this.resetFn = resetFn;
this.pool = [];
for (let i = 0; i < size; i++) {
this.pool.push(createFn());
}
}
get() {
return this.pool.length > 0 ? this.pool.pop() : this.createFn();
}
release(obj) {
this.resetFn(obj);
this.pool.push(obj);
}
}
// 使用
const particlePool = new Pool(
() => ({ x: 0, y: 0, vx: 0, vy: 0, life: 0 }),
(p) => { p.x = 0; p.y = 0; p.life = 0; }
);
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago First seen · 168 lines · 10 tokens per session scan A ef124571bdf6
canvas-optimize is a skill published in the GitHub repository guyulong/cn-agent-skills (3 stars, last pushed 4mo ago), licensed MIT. It adds 10 tokens to every session and 1,045 once invoked, about $0.0000 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
umg-widgets
Create and modify UMG Widget Blueprints (UI) — build the widget hierarchy, set properties, style fonts/brushes, author widget animations, bind events, capture previews, run PIE checks, and wire MVVM ViewModels. Use when the user asks to create a UI/HUD/menu, add or arrange widgets (Button, TextBlock, Image, panels)…
ecom-details-image
A guide for planning still images used to sell or explain products, including main product pictures, detail-page images, banners, lifestyle scenes, packaging, comparisons, and product demonstrations. It can provide image prompts or, when explicitly requested, use the project's own image-generation route.
tapcanvas-source-coverage
A source-coverage checker for long texts, subtitles, interviews, videos, and collections of files. It records which parts were actually read and links them to evidence that can be checked later.
tapcanvas-style-pack
A visual-style planning skill for creating, extracting, applying, updating, or checking a project's reusable look. A style pack describes transferable choices such as colour, lighting, composition, materials, and camera movement without copying the specific content of a reference image.
tvc-ad-director
A directing guide for television commercials and other short product or brand adverts. It turns a business goal into one clear message, visual plan, and handoff for production.
starting
The wiring order for a Lattice game — canvas, surface, camera, palette, light, depth sorter, loop and input — and the shape a first build should take so it does not come out a diorama. Use when starting an isometric game, setting up a Lattice project, writing the boot or main.ts, adding a game loop to a canvas…