copy-ninja-kakashi
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "copy-ninja-kakashi" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-6f454e5778663d40c73a894d7a7d0ddce7ddf67063e5dbadd7f14076f21798af. Verify the upstream source and version against https://skillhub.cn/skills/user_2a26b415/copy-ninja-kakashi before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Copy Ninja Kakashi skill: a specialized skill for pixel-perfect replication of web components. When a user requests copying/replicating/deriving a website section or requests a pixel-level match (“make it the same as xxx”), it helps an AI Agent provide end-to-end SOPs from reconnaissance and analysis to code implementation, screenshot comparison, and interaction refinement.
Introduction source: third_party · user_2a26b415 · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Limits and differences
- ```
- Testing
- Not tested
Browse files
Frontmatter
name: "copy-ninja-kakashi"
description: "复制忍者卡卡西:像素级复刻任意网页组件。当用户要求「复制/复刻/抄袭/借鉴」某个网站的区块、模块或组件,提供目标 URL 要求「做成和 xxx 一样的效果」,或要求「像素级对齐/指纹级还原/一模一样」时调用。提供从侦察分析、代码实现、截图比对到交互打磨的全流程 SOP。Pixel-perfectly replicates any web component from a target URL. Invoke when user asks to copy/clone/replicate a website section, block, or component from another webpage."Copy Ninja Kakashi (复制忍者卡卡西)
"在艺术面前,抄袭也是一种致敬。" —— 以写轮眼之力,看穿一切DOM与CSS,实现指纹级组件复刻。
Overview
Copy Ninja Kakashi 是一套像素级复刻任意网页组件的完整方法论。基于实战经验总结(成功复刻北大计算机学院官网新闻区块),提供从分析到调试的全流程SOP,确保复刻效果达到"指纹级"相似度。
Usage Examples (使用案例)
案例1:复刻官网新闻区块(本技能起源案例)
用户诉求: "把北大计算机学院官网首页的新闻轮播区块复刻到我的项目里,要一模一样。"
执行路径:
- 侦察 — Playwright 打开目标 URL,1500px 宽度截取新闻区块完整截图作为比对基准;DevTools 拆解 DOM,输出层级树(标题区 + 左侧40%轮播 + 右侧60%列表 + 石狮子装饰)。
- 提取 — Computed 面板逐元素抓取计算后样式:宋体标题 36px、主色 #8F000B、区块背景 #F8F5F0、粉色装饰圆 opacity 0.26;从 Network 面板拿到石狮子、飘带图片真实 URL 并
curl下载到public/images/decorations/。 - 实现 — 先定义色彩/尺寸常量,搭 DOM 骨架(背景层 z-0 / 内容层 z-5 / 前景装饰 z-10),再由外到内填充 inline style 精确像素值。
- 对齐 — 截取我方组件图,与参考图半透明叠加比对,修正位置偏差至 ≤2px。
- 打磨 — 实现 5 秒自动轮播 + 点击列表联动轮播(暂停15秒)+ 悬停浅色背景。
产出: 元素偏差 ≤2px、色值误差 ≤1、交互行为一致的复刻组件。
案例2:借鉴竞品的卡片式定价模块
用户诉求: "参考 stripe.com 的定价卡片,做成我们产品的样式。"
关键动作: 重点提取卡片圆角、box-shadow 层次、悬停时的 transform 上浮与阴影加深;用内部百分比容器对齐不同 max-width 下的比例(见 Step 3.3 容器系统分析)。
案例3:修复复刻后的层级/截断问题
用户诉求: "我照着做了但装饰图被导航栏盖住了 / 飘带底部被切掉。"
排障路径: 直接查 Phase 3 Step 3.2 常见问题库 —— z-index 失效多因父级创建了层叠上下文(有 transform/opacity/z-index),需把高层级节点移到父容器外;背景截断改用 overflowX:hidden 并给容器留负 margin 延伸空间。
When to Invoke
必须调用此技能的场景:
- 用户要求"复制/复刻/抄袭/借鉴"某个网站的组件/区块/页面效果
- 用户提供目标URL并要求"做成和xxx一样的效果"
- 用户要求"像素级对齐"、"指纹级抄袭"、"一模一样"
- 需要参考其他网站的UI设计来实现当前项目的功能
Core Philosophy: 7 Layers of Replication
复刻不是简单的"看起来像",而是从7个层面逐一还原:
| 层级 | 内容 | 还原度要求 |
|---|---|---|
| 1. Layout | 布局结构、比例、间距 | 100% |
| 2. Color | 色彩方案、透明度、渐变 | 色值误差≤1 |
| 3. Typography | 字体、字号、字重、行高 | 误差≤1px |
| 4. Decoration | 装饰元素(圆点、线条、图案) | 位置/尺寸一致 |
| 5. Background | 背景图片、纹理、层级 | 完整不截断 |
| 6. Interaction | 轮播、悬停、联动效果 | 行为一致 |
| 7. Mood | 整体视觉氛围、细腻感 | 肉眼不可区分 |
Step-by-Step SOP
Phase 1: Reconnaissance (侦察阶段)
Step 1.1: 获取参考截图
使用浏览器工具打开目标URL,截取目标组件的完整截图:
- 桌面端(1440px/1500px宽度)
- 记录截图保存路径,作为后续比对基准
- 如果组件有交互状态(悬停、选中、轮播),需要截取各状态截图
截图脚本模板(Playwright):
// .trae/screenshot-reference.js
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage({ viewport: { width: 1500, height: 1200 } });
await page.goto('TARGET_URL', { waitUntil: 'networkidle' });
// 移除可能的弹窗/遮罩
await page.evaluate(() => {
document.querySelectorAll('[style*="position: fixed"]').forEach(el => {
if (el.style.zIndex > 100) el.remove();
});
});
// 截取目标区域(通过selector定位)
const element = await page.$('TARGET_SELECTOR');
await element.screenshot({ path: '.trae/reference-target.png' });
await browser.close();
})();
Step 1.2: DOM结构拆解
在浏览器开发者工具中,逐层拆解目标组件的DOM树:
- 外层容器:记录class、宽度、max-width、padding、margin、background、position
- 布局方式:flex/grid/absolute,子元素比例分配
- 子模块划分:将组件拆分为独立子模块(如标题区、轮播区、列表区、装饰区)
- 层级关系:记录每个元素的z-index和position属性,绘制层叠上下文树
输出: 用文字描述DOM层级结构,例如:
section.home1 (relative, bg:#F8F5F0)
├── container (max-width:1600px, padding:0 60px)
│ ├── title-block (flex, justify-between)
│ │ ├── title-group (relative)
│ │ │ ├── 粉色圆装饰1 (absolute, 58x58, opacity:0.26)
│ │ │ ├── 粉色圆装饰2 (absolute, 34x34, opacity:0.45)
│ │ │ ├── h2 中文标题 (宋体, 36px)
│ │ │ └── h6 EN副标题 (Cormorant Garamond, 11px)
│ │ └── "查看更多"链接 (absolute, right:0)
│ └── content-wrapper (flex)
│ ├── left: carousel (width:40%)
│ └── right: news-list (width:60%)
└── 石狮子装饰 (absolute, z-index:95)
Step 1.3: CSS样式提取
对每个元素,在DevTools的"Computed"面板中提取计算后样式(不要看CSS文件中的定义,要看最终计算值):
必提取的样式属性:
布局类:display, position, width, height, max-width, min-width,
padding (top/right/bottom/left), margin, gap, flex/grid属性
字体类:font-family, font-size, font-weight, line-height, letter-spacing,
text-align, color, text-transform, text-decoration
背景类:background-color, background-image, background-size, background-position,
background-repeat, opacity
边框类:border, border-radius, box-shadow
定位类:top, right, bottom, left, z-index, transform
其他:cursor, transition, overflow
颜色提取技巧:
- 使用取色器工具直接吸取屏幕颜色
- 注意区分"主色"、"辅助色"、"文字色"、"背景色"
- 记录颜色的使用场景(如:红色用于标题和强调,灰色用于次要文字)
Step 1.4: 资源文件清单
列出所有需要下载的图片/字体资源:
- 背景图片(装饰纹理、飘带、图案)
- 内容图片(轮播图、缩略图)
- 装饰图标(点阵、分隔符、箭头)
- 特殊字体(如果有webfont)
图片下载命令:
# 下载图片到public/images/对应目录
curl -o public/images/decorations/filename.ext "IMAGE_URL"
# 注意:需要从Network面板或DOM的src/background-image中获取真实URL
Phase 2: Implementation (实现阶段)
Step 2.1: 定义设计变量
在组件顶部定义CSS常量,确保颜色、尺寸统一管理:
// 色彩系统(从目标网站提取)
const BRAND_PRIMARY = '#8F000B'; // 主色(如北大红)
const BRAND_DARK = '#333333'; // 主要文字色
const BRAND_GRAY = '#959595'; // 次要文字色
const BRAND_LIGHT_GRAY = '#B8B8B8'; // 辅助文字色
const BRAND_BG = '#F8F5F0'; // 区块背景色
const BRAND_ACCENT = '#E8A5A9'; // 强调装饰色(粉色圆)
const BRAND_CARD_BG = '#FFFFFF'; // 卡片背景色
// 尺寸系统
const CONTAINER_MAX = 1600; // 容器最大宽度
const SECTION_PADDING_TOP = 58; // 区块上padding
const SECTION_PADDING_BOTTOM = 60; // 区块下padding
Step 2.2: DOM结构搭建
按照Phase 1拆解的结构,先搭出完整的DOM骨架(不写样式),确保结构层次正确:
重要原则:
- 不要急于写样式,先把HTML结构写对
- 用className注释每个区块的用途
- 装饰元素作为独立节点放在对应位置
- 背景装饰放在z-index最低的层
<section className="relative w-full" style={{ backgroundColor: BRAND_BG }}>
{/* 背景装饰层 - z-index最低 */}
<div className="absolute pointer-events-none" style={{ zIndex: 0 }}>
{/* 飘带、纹理等 */}
</div>
{/* 内容层 - z-index中等 */}
<div className="container-custom relative" style={{ zIndex: 5 }}>
{/* 标题区 */}
{/* 内容区 */}
</div>
{/* 前景装饰 - z-index较高 */}
<div className="absolute pointer-events-none" style={{ zIndex: 10 }}>
{/* 石狮子等需要露出的装饰 */}
</div>
</section>
Step 2.3: 样式填充(由外到内)
按照"外层容器 → 布局框架 → 子模块 → 细节装饰"的顺序填充样式:
字体还原优先级:
- 中文字体栈:
"Source Han Serif SC","Noto Serif SC","STSong","SimSun",serif(宋体) - 英文/数字字体栈:
"Cormorant Garamond", "Times New Roman", Georgia, serif(衬线体) - 无衬线字体栈:
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif
尺寸还原原则:
- 严格按照提取的像素值设置,不要用Tailwind默认尺寸近似
- 当Tailwind类无法精确表达时,使用inline style
- 间距使用像素值精确控制,不要用
gap-4、p-6等模糊值
示例:精确样式写法
// ❌ 模糊写法(不够精确)
<h2 className="text-3xl font-bold text-red-800 mb-2">标题</h2>
// ✅ 精确写法(指纹级还原)
<h2 style={{
fontSize: '36px',
fontWeight: 400,
color: BRAND_DARK,
lineHeight: '40px',
margin: '0 0 5px 0',
fontFamily: '"Source Han Serif SC","Noto Serif SC","STSong","SimSun",serif',
letterSpacing: '0.08em'
}}>标题</h2>
Step 2.4: 装饰元素实现
点阵图案(JuzhenDots): 用SVG绘制,保持与原图一致的点大小和间距:
const JuzhenDots = ({ className = '', style = {} }) => (
<svg width="44" height="44" viewBox="0 0 44 44" className={className} style={style}>
<g fill="currentColor">
{/* 4x4点阵,每个点半径2px,间距10px */}
{Array.from({ length: 4 }).map((_, row) =>
Array.from({ length: 4 }).map((_, col) => (
<circle key={`${row}-${col}`} cx={6 + col * 10} cy={6 + row * 10} r="2" />
))
)}
</g>
</svg>
);
圆形装饰:
// 半透明粉色圆(绝对定位)
<div className="absolute rounded-full" style={{
width: '58px',
height: '58px',
background: BRAND_ACCENT,
opacity: 0.26,
right: '-14px',
top: '-12px'
}} />
自定义箭头/图标: 优先用inline SVG,确保颜色和大小可控。
Phase 3: Debugging & Alignment (调试对齐阶段)
Step 3.1: 截图比对法
核心调试手段: 半透明叠加比对
- 先截取当前实现的截图
- 用图片编辑工具将参考图半透明叠加在截图上
- 逐一对比每个元素的位置、尺寸差异
- 修正偏差,重复直到完全重合
自动化截图脚本(我方实现):
// .trae/screenshot-our-component.js
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage({ viewport: { width: 1500, height: 1200 } });
await page.goto('http://localhost:3000', { waitUntil: 'networkidle' });
// 移除ESLint错误遮罩(开发环境常见)
await page.evaluate(() => {
document.querySelectorAll('[style*="position: fixed"]').forEach(el => {
const bg = window.getComputedStyle(el).backgroundColor;
if (bg.includes('255, 0, 0') || el.querySelector('[role="alert"]')) el.remove();
});
});
// 等待目标组件渲染
await page.waitForSelector('TARGET_COMPONENT_SELECTOR');
const element = await page.$('TARGET_COMPONENT_SELECTOR');
await element.screenshot({ path: '.trae/our-component.png' });
await browser.close();
})();
Step 3.2: 常见问题解决方案(血的教训)
问题1:z-index不生效/元素被遮挡
- 根因: 父元素创建了新的层叠上下文(stacking context)。当父元素有
position:relative/absolute且设置了z-index(任何值),或者有opacity<1、transform、filter等属性时,会创建层叠上下文,子元素的z-index无法突破父级。 - 解决方案:
- 将需要高层级的元素DOM节点移到创建层叠上下文的父容器外部
- 兄弟元素之间通过z-index控制层级(同一层叠上下文内z-index才有效)
- z-index数值规划建议:
- 背景装饰:z-0
- 内容主体:z-5
- 前景装饰:z-10
- 绝对定位交互元素:z-20
- fixed悬浮按钮:z-90
- 需要突破的装饰:z-95(注意要在层叠上下文外)
- 导航栏/Modal:z-100+
问题2:背景图被截断/显示不全
- 根因: 容器overflow:hidden裁剪、background-size设置错误、容器尺寸不够
- 解决方案:
- 如果只需要水平方向裁剪,用
overflowX: 'hidden'代替overflow: 'hidden' - 背景图容器使用足够大的尺寸(可以用负margin扩大范围)
- 使用
backgroundSize: 'cover'或'100% 100%'根据需要调整 - 飘带/波浪边缘图片:容器高度要足够容纳完整波浪,通常需要bottom设为负值延伸
- 如果只需要水平方向裁剪,用
问题3:元素间出现不明间隙
- 根因: inline-block空白字符、margin合并、line-height影响
- 解决方案:
- 图片下方间隙:给img设置
display: block - 标题条覆盖轮播图:用
marginTop: '-52px'负margin上移 - 全局reset确保margin/padding归零
- 图片下方间隙:给img设置
问题4:不同宽度下比例失调
- 根因: 固定像素宽度在不同max-width容器中比例不一致
- 解决方案:
- 先分析项目的container系统(max-width、padding断点)
- 内部容器使用百分比宽度(如width: '86%')而非固定像素
- 外层装饰容器使用
left: 50%; transform: translateX(-50%)居中,并设置maxWidth匹配内容容器 - 示例:
<div className="absolute pointer-events-none" style={{ left: '50%', transform: 'translateX(-50%)', width: '86%', maxWidth: 'calc(1600px * 0.86)' // 匹配container max-width * 百分比 }}>
问题5:开发环境ESLint遮罩遮挡页面
- 解决方案: 截图脚本中加入移除逻辑:
await page.evaluate(() => { document.querySelectorAll('iframe, [style*="position: fixed"]').forEach(el => { const style = window.getComputedStyle(el); if (parseInt(style.zIndex) > 100) el.remove(); }); });
Step 3.3: 容器系统分析(重要!)
在开始样式前,必须先分析当前项目的容器系统:
- 查看全局CSS中container或container-custom的定义:
- max-width是多少?(如1600px)
- 各断点下的padding是多少?
- 计算内容区域的真实宽度:
- 内容宽度 = max-width - padding-left - padding-right
- 参考网站的内容区域宽度也要计算
- 如果两者不同,使用内部百分比容器来对齐比例
// 示例:项目container max-width:1600px, padding: 0 60px
// 参考网站内容宽度约 1180px
// 那么内部容器宽度 = 1180 / (1600 - 120) ≈ 80% → 实际调试验证后设为86%
Phase 4: Interaction & Polish (交互与打磨)
Step 4.1: 轮播功能
const [slideIdx, setSlideIdx] = useState(0);
const [autoPaused, setAutoPaused] = useState(false);
// 自动轮播
useEffect(() => {
if (autoPaused) return;
const timer = setInterval(() => {
setSlideIdx(prev => (prev + 1) % newsItems.length);
}, 5000);
return () => clearInterval(timer);
}, [autoPaused, newsItems.length]);
// 点击联动
const selectNews = (idx) => {
setSlideIdx(idx);
setAutoPaused(true);
setTimeout(() => setAutoPaused(false), 15000); // 点击后暂停15秒
};
Step 4.2: 悬停效果
- 链接悬停:
hover:opacity-75 transition-opacity - 列表项悬停:
hover:bg-[#FAF6F1]/50浅色背景 - 激活状态:文字变主色+加粗+浅色背景
Step 4.3: 响应式适配
使用Tailwind的lg:前缀(1024px断点):
<lg(移动端):堆叠布局,隐藏复杂装饰>=lg(桌面端):完整复刻布局
{/* 桌面端石狮子 */}
<div className="hidden lg:block absolute ...">...</div>
{/* 移动端布局 */}
<div className="lg:hidden">...</div>
Critical Rules (铁则)
- 永远看Computed样式,不看CSS源码:CSS文件中的定义可能被覆盖,Computed面板才是真实渲染值
- 装饰元素用pointer-events-none:避免装饰图片阻挡鼠标交互
- 先结构后样式:DOM结构不对,样式怎么调都不对
- 截图是最好的调试工具:肉眼不可靠,截图叠加比对才能发现1px的偏差
- z-index规划先行:动手前先规划好各层z-index值,避免后期"z-index打地鼠"
- 图片必须本地化:不要直接引用外部URL,下载到public目录
- 单一数据源:轮播图和列表如果内容联动,使用同一个数组数据源,避免内容重复或不一致
- 不要害怕负margin:精确的像素偏移经常需要负margin来实现覆盖/对齐效果
- overflow要精确控制:
overflow:hidden会同时裁剪XY方向,只需要一个方向时用overflowX/overflowY - 颜色变量统一管理:所有颜色值定义为const常量,不要在inline style中硬编码色值
Verification Checklist (验收清单)
完成复刻后,逐项检查:
- [ ] 桌面端1500px宽度下截图与参考图叠加比对,元素位置偏差≤2px
- [ ] 所有文字字体、字号、颜色、行高、字重与参考一致
- [ ] 装饰元素(圆点、线条、图案)位置和尺寸正确
- [ ] 背景图/飘带完整显示,无截断
- [ ] 石狮子等前景装饰正确露出,不被遮挡也不遮挡交互元素
- [ ] 轮播图自动播放正常
- [ ] 点击右侧列表项能联动左侧轮播图
- [ ] 悬停效果正确
- [ ] 移动端(<1024px)布局可用,无错位
- [ ] ESLint/控制台无报错
- [ ] 整体视觉氛围与参考图一致,"感觉"对了
File Structure Convention (文件组织约定)
.trae/
├── screenshot-reference.js # 截取参考网站
├── screenshot-our-component.js # 截取我方实现
├── reference-target.png # 参考截图
└── our-component.png # 我方截图
public/images/decorations/ # 装饰图片(石狮子、飘带等)
public/images/content/ # 内容图片
src/components/target-component/ # 组件目录(如果拆分)
└── ComponentName.js # 主组件文件
Remember
写轮眼的真正力量,不是复制术的形态,而是复制术者的意图。
复刻组件不是机械地复制每一个像素,而是理解原设计师的布局逻辑、视觉节奏、层级关系,然后用你自己的代码重新构建出来。当你理解了"为什么这样设计",你就能完美复现"看起来是什么样子"。
一旦复制完成,这个术就是你的了。 —— 卡卡西
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供从侦察分析、代码实现、截图比对到交互打磨的全流程SOP,解决用户明确的核心任务痛点
- 包含具体实战案例(北大计算机学院官网新闻区块)和详细执行路径,实用性强
- 覆盖7个复刻层级(布局、色彩、字体、装饰、背景、交互、氛围),方法论完整
Highlights
- 触发词精准完整,覆盖'复制/复刻/抄袭/借鉴'、'像素级对齐'、'指纹级还原'等多种变体
- 边界清晰,明确列出必须调用此技能的具体场景
- 中英文双语触发描述,覆盖更广泛的用户表达
Highlights
- Phase/步骤清晰(侦察→实现→调试→交互),有明确的出口条件和验收清单
- 包含端到端完整示例和具体代码模板(Playwright截图脚本、DOM结构描述)
- frontmatter完整,文件组织约定清晰,单文件结构合理
Highlights
- 工具来源明确(Playwright、DevTools、curl),参数具体可执行
- 覆盖主要异常场景(z-index失效、背景截断、元素间隙、容器比例失调)并提供解决方案
- 不可逆操作(图片下载)有明确路径和目录约定,交互打磨有具体实现代码
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Screenshots or screen capture
Capture only a selected window or region. Avoid secrets and private records and review captures before sharing.
Mentioned in main document · lines 88, 299
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- localhost
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.