[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6AE626TZJZ6R8QBZD56VYG8":3,"skill-same:01M6AE626TZJZ6R8QBZD56VYG8":194},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":52,"linkOnly":53,"markdownContent":54,"markdownBody":55,"frontMatter":56,"refName":57,"commitSha":58,"skillDirectory":59,"forksCount":60,"repositoryHtmlUrl":61,"repositoryHomepageUrl":62,"ownerHtmlUrl":63,"ownerBlogUrl":64,"ownerDescription":65,"updatedAt":66,"install":67,"resources":80},"01M6AE626TZJZ6R8QBZD56VYG8","claude-d3js-skill","D3.js 交互式数据可视化","Creating interactive data visualisations using d3.js. This skill should be used when creating custom charts, graphs, network diagrams, geographic visualisations, or any complex SVG-based data visualisation that requires fine-grained control over visual elements, transitions, or interactions. Use this for bespoke visualisations beyond standard charting libraries, whether in React, Vue, Svelte, vanilla JavaScript, or any other environment.","使用 d3.js 创建交互式数据可视化。当需要创建自定义图表、图形、网络图、地理可视化，或任何需要对视觉元素、过渡效果或交互进行精细控制的复杂基于 SVG 的数据可视化时，应使用此技能。适用于超越标准图表库的定制可视化，无论是在 React、Vue、Svelte、原生 JavaScript 还是其他任何环境中。","davila7\u002Fclaude-code-templates","davila7","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6216945?v=4","01M6ADEWWFPS191NFM0Y1EX1JH","Daniel Avila","01M6ADJHGM78PHQRD3XZTFDVKK",33602,"MIT",null,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Fclaude-d3js-skill\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQGD4CMBM6B4PWSM1NXGT9","数据分析与报告","SCENARIO","使用场景",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQGD5CX980XNXCJKQF70BY","数据分析师","PROFESSION","适用职业",[31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],"claude d3js","claude d3js skill","use","when","custom","for","visualisation","SVG","d3","elements","svelte","diagrams","javascript","environment","Charts","data","network","vue","Charting","libraries","react","2026-11-10 10:12:30",false,"---\nname: claude-d3js-skill\ndescription: Creating interactive data visualisations using d3.js. This skill should be used when creating custom charts, graphs, network diagrams, geographic visualisations, or any complex SVG-based data visualisation that requires fine-grained control over visual elements, transitions, or interactions. Use this for bespoke visualisations beyond standard charting libraries, whether in React, Vue, Svelte, vanilla JavaScript, or any other environment.\n---\n\n# D3.js Visualisation\n\n## Overview\n\nThis skill provides guidance for creating sophisticated, interactive data visualisations using d3.js. D3.js (Data-Driven Documents) excels at binding data to DOM elements and applying data-driven transformations to create custom, publication-quality visualisations with precise control over every visual element. The techniques work across any JavaScript environment, including vanilla JavaScript, React, Vue, Svelte, and other frameworks.\n\n## When to use d3.js\n\n**Use d3.js for:**\n- Custom visualisations requiring unique visual encodings or layouts\n- Interactive explorations with complex pan, zoom, or brush behaviours\n- Network\u002Fgraph visualisations (force-directed layouts, tree diagrams, hierarchies, chord diagrams)\n- Geographic visualisations with custom projections\n- Visualisations requiring smooth, choreographed transitions\n- Publication-quality graphics with fine-grained styling control\n- Novel chart types not available in standard libraries\n\n**Consider alternatives for:**\n- 3D visualisations - use Three.js instead\n\n## Core workflow\n\n### 1. Set up d3.js\n\nImport d3 at the top of your script:\n\n```javascript\nimport * as d3 from 'd3';\n```\n\nOr use the CDN version (7.x):\n\n```html\n\u003Cscript src=\"https:\u002F\u002Fd3js.org\u002Fd3.v7.min.js\">\u003C\u002Fscript>\n```\n\nAll modules (scales, axes, shapes, transitions, etc.) are accessible through the `d3` namespace.\n\n### 2. Choose the integration pattern\n\n**Pattern A: Direct DOM manipulation (recommended for most cases)**\nUse d3 to select DOM elements and manipulate them imperatively. This works in any JavaScript environment:\n\n```javascript\nfunction drawChart(data) {\n  if (!data || data.length === 0) return;\n\n  const svg = d3.select('#chart'); \u002F\u002F Select by ID, class, or DOM element\n\n  \u002F\u002F Clear previous content\n  svg.selectAll(\"*\").remove();\n\n  \u002F\u002F Set up dimensions\n  const width = 800;\n  const height = 400;\n  const margin = { top: 20, right: 30, bottom: 40, left: 50 };\n\n  \u002F\u002F Create scales, axes, and draw visualisation\n  \u002F\u002F ... d3 code here ...\n}\n\n\u002F\u002F Call when data changes\ndrawChart(myData);\n```\n\n**Pattern B: Declarative rendering (for frameworks with templating)**\nUse d3 for data calculations (scales, layouts) but render elements via your framework:\n\n```javascript\nfunction getChartElements(data) {\n  const xScale = d3.scaleLinear()\n    .domain([0, d3.max(data, d => d.value)])\n    .range([0, 400]);\n\n  return data.map((d, i) => ({\n    x: 50,\n    y: i * 30,\n    width: xScale(d.value),\n    height: 25\n  }));\n}\n\n\u002F\u002F In React: {getChartElements(data).map((d, i) => \u003Crect key={i} {...d} fill=\"steelblue\" \u002F>)}\n\u002F\u002F In Vue: v-for directive over the returned array\n\u002F\u002F In vanilla JS: Create elements manually from the returned data\n```\n\nUse Pattern A for complex visualisations with transitions, interactions, or when leveraging d3's full capabilities. Use Pattern B for simpler visualisations or when your framework prefers declarative rendering.\n\n### 3. Structure the visualisation code\n\nFollow this standard structure in your drawing function:\n\n```javascript\nfunction drawVisualization(data) {\n  if (!data || data.length === 0) return;\n\n  const svg = d3.select('#chart'); \u002F\u002F Or pass a selector\u002Felement\n  svg.selectAll(\"*\").remove(); \u002F\u002F Clear previous render\n\n  \u002F\u002F 1. Define dimensions\n  const width = 800;\n  const height = 400;\n  const margin = { top: 20, right: 30, bottom: 40, left: 50 };\n  const innerWidth = width - margin.left - margin.right;\n  const innerHeight = height - margin.top - margin.bottom;\n\n  \u002F\u002F 2. Create main group with margins\n  const g = svg.append(\"g\")\n    .attr(\"transform\", `translate(${margin.left},${margin.top})`);\n\n  \u002F\u002F 3. Create scales\n  const xScale = d3.scaleLinear()\n    .domain([0, d3.max(data, d => d.x)])\n    .range([0, innerWidth]);\n\n  const yScale = d3.scaleLinear()\n    .domain([0, d3.max(data, d => d.y)])\n    .range([innerHeight, 0]); \u002F\u002F Note: inverted for SVG coordinates\n\n  \u002F\u002F 4. Create and append axes\n  const xAxis = d3.axisBottom(xScale);\n  const yAxis = d3.axisLeft(yScale);\n\n  g.append(\"g\")\n    .attr(\"transform\", `translate(0,${innerHeight})`)\n    .call(xAxis);\n\n  g.append(\"g\")\n    .call(yAxis);\n\n  \u002F\u002F 5. Bind data and create visual elements\n  g.selectAll(\"circle\")\n    .data(data)\n    .join(\"circle\")\n    .attr(\"cx\", d => xScale(d.x))\n    .attr(\"cy\", d => yScale(d.y))\n    .attr(\"r\", 5)\n    .attr(\"fill\", \"steelblue\");\n}\n\n\u002F\u002F Call when data changes\ndrawVisualization(myData);\n```\n\n### 4. Implement responsive sizing\n\nMake visualisations responsive to container size:\n\n```javascript\nfunction setupResponsiveChart(containerId, data) {\n  const container = document.getElementById(containerId);\n  const svg = d3.select(`#${containerId}`).append('svg');\n\n  function updateChart() {\n    const { width, height } = container.getBoundingClientRect();\n    svg.attr('width', width).attr('height', height);\n\n    \u002F\u002F Redraw visualisation with new dimensions\n    drawChart(data, svg, width, height);\n  }\n\n  \u002F\u002F Update on initial load\n  updateChart();\n\n  \u002F\u002F Update on window resize\n  window.addEventListener('resize', updateChart);\n\n  \u002F\u002F Return cleanup function\n  return () => window.removeEventListener('resize', updateChart);\n}\n\n\u002F\u002F Usage:\n\u002F\u002F const cleanup = setupResponsiveChart('chart-container', myData);\n\u002F\u002F cleanup(); \u002F\u002F Call when component unmounts or element removed\n```\n\nOr use ResizeObserver for more direct container monitoring:\n\n```javascript\nfunction setupResponsiveChartWithObserver(svgElement, data) {\n  const observer = new ResizeObserver(() => {\n    const { width, height } = svgElement.getBoundingClientRect();\n    d3.select(svgElement)\n      .attr('width', width)\n      .attr('height', height);\n\n    \u002F\u002F Redraw visualisation\n    drawChart(data, d3.select(svgElement), width, height);\n  });\n\n  observer.observe(svgElement.parentElement);\n  return () => observer.disconnect();\n}\n```\n\n## Common visualisation patterns\n\n### Bar chart\n\n```javascript\nfunction drawBarChart(data, svgElement) {\n  if (!data || data.length === 0) return;\n\n  const svg = d3.select(svgElement);\n  svg.selectAll(\"*\").remove();\n\n  const width = 800;\n  const height = 400;\n  const margin = { top: 20, right: 30, bottom: 40, left: 50 };\n  const innerWidth = width - margin.left - margin.right;\n  const innerHeight = height - margin.top - margin.bottom;\n\n  const g = svg.append(\"g\")\n    .attr(\"transform\", `translate(${margin.left},${margin.top})`);\n\n  const xScale = d3.scaleBand()\n    .domain(data.map(d => d.category))\n    .range([0, innerWidth])\n    .padding(0.1);\n\n  const yScale = d3.scaleLinear()\n    .domain([0, d3.max(data, d => d.value)])\n    .range([innerHeight, 0]);\n\n  g.append(\"g\")\n    .attr(\"transform\", `translate(0,${innerHeight})`)\n    .call(d3.axisBottom(xScale));\n\n  g.append(\"g\")\n    .call(d3.axisLeft(yScale));\n\n  g.selectAll(\"rect\")\n    .data(data)\n    .join(\"rect\")\n    .attr(\"x\", d => xScale(d.category))\n    .attr(\"y\", d => yScale(d.value))\n    .attr(\"width\", xScale.bandwidth())\n    .attr(\"height\", d => innerHeight - yScale(d.value))\n    .attr(\"fill\", \"steelblue\");\n}\n\n\u002F\u002F Usage:\n\u002F\u002F drawBarChart(myData, document.getElementById('chart'));\n```\n\n### Line chart\n\n```javascript\nconst line = d3.line()\n  .x(d => xScale(d.date))\n  .y(d => yScale(d.value))\n  .curve(d3.curveMonotoneX); \u002F\u002F Smooth curve\n\ng.append(\"path\")\n  .datum(data)\n  .attr(\"fill\", \"none\")\n  .attr(\"stroke\", \"steelblue\")\n  .attr(\"stroke-width\", 2)\n  .attr(\"d\", line);\n```\n\n### Scatter plot\n\n```javascript\ng.selectAll(\"circle\")\n  .data(data)\n  .join(\"circle\")\n  .attr(\"cx\", d => xScale(d.x))\n  .attr(\"cy\", d => yScale(d.y))\n  .attr(\"r\", d => sizeScale(d.size)) \u002F\u002F Optional: size encoding\n  .attr(\"fill\", d => colourScale(d.category)) \u002F\u002F Optional: colour encoding\n  .attr(\"opacity\", 0.7);\n```\n\n### Chord diagram\n\nA chord diagram shows relationships between entities in a circular layout, with ribbons representing flows between them:\n\n```javascript\nfunction drawChordDiagram(data) {\n  \u002F\u002F data format: array of objects with source, target, and value\n  \u002F\u002F Example: [{ source: 'A', target: 'B', value: 10 }, ...]\n\n  if (!data || data.length === 0) return;\n\n  const svg = d3.select('#chart');\n  svg.selectAll(\"*\").remove();\n\n  const width = 600;\n  const height = 600;\n  const innerRadius = Math.min(width, height) * 0.3;\n  const outerRadius = innerRadius + 30;\n\n  \u002F\u002F Create matrix from data\n  const nodes = Array.from(new Set(data.flatMap(d => [d.source, d.target])));\n  const matrix = Array.from({ length: nodes.length }, () => Array(nodes.length).fill(0));\n\n  data.forEach(d => {\n    const i = nodes.indexOf(d.source);\n    const j = nodes.indexOf(d.target);\n    matrix[i][j] += d.value;\n    matrix[j][i] += d.value;\n  });\n\n  \u002F\u002F Create chord layout\n  const chord = d3.chord()\n    .padAngle(0.05)\n    .sortSubgroups(d3.descending);\n\n  const arc = d3.arc()\n    .innerRadius(innerRadius)\n    .outerRadius(outerRadius);\n\n  const ribbon = d3.ribbon()\n    .source(d => d.source)\n    .target(d => d.target);\n\n  const colourScale = d3.scaleOrdinal(d3.schemeCategory10)\n    .domain(nodes);\n\n  const g = svg.append(\"g\")\n    .attr(\"transform\", `translate(${width \u002F 2},${height \u002F 2})`);\n\n  const chords = chord(matrix);\n\n  \u002F\u002F Draw ribbons\n  g.append(\"g\")\n    .attr(\"fill-opacity\", 0.67)\n    .selectAll(\"path\")\n    .data(chords)\n    .join(\"path\")\n    .attr(\"d\", ribbon)\n    .attr(\"fill\", d => colourScale(nodes[d.source.index]))\n    .attr(\"stroke\", d => d3.rgb(colourScale(nodes[d.source.index])).darker());\n\n  \u002F\u002F Draw groups (arcs)\n  const group = g.append(\"g\")\n    .selectAll(\"g\")\n    .data(chords.groups)\n    .join(\"g\");\n\n  group.append(\"path\")\n    .attr(\"d\", arc)\n    .attr(\"fill\", d => colourScale(nodes[d.index]))\n    .attr(\"stroke\", d => d3.rgb(colourScale(nodes[d.index])).darker());\n\n  \u002F\u002F Add labels\n  group.append(\"text\")\n    .each(d => { d.angle = (d.startAngle + d.endAngle) \u002F 2; })\n    .attr(\"dy\", \"0.31em\")\n    .attr(\"transform\", d => `rotate(${(d.angle * 180 \u002F Math.PI) - 90})translate(${outerRadius + 30})${d.angle > Math.PI ? \"rotate(180)\" : \"\"}`)\n    .attr(\"text-anchor\", d => d.angle > Math.PI ? \"end\" : null)\n    .text((d, i) => nodes[i])\n    .style(\"font-size\", \"12px\");\n}\n```\n\n### Heatmap\n\nA heatmap uses colour to encode values in a two-dimensional grid, useful for showing patterns across categories:\n\n```javascript\nfunction drawHeatmap(data) {\n  \u002F\u002F data format: array of objects with row, column, and value\n  \u002F\u002F Example: [{ row: 'A', column: 'X', value: 10 }, ...]\n\n  if (!data || data.length === 0) return;\n\n  const svg = d3.select('#chart');\n  svg.selectAll(\"*\").remove();\n\n  const width = 800;\n  const height = 600;\n  const margin = { top: 100, right: 30, bottom: 30, left: 100 };\n  const innerWidth = width - margin.left - margin.right;\n  const innerHeight = height - margin.top - margin.bottom;\n\n  \u002F\u002F Get unique rows and columns\n  const rows = Array.from(new Set(data.map(d => d.row)));\n  const columns = Array.from(new Set(data.map(d => d.column)));\n\n  const g = svg.append(\"g\")\n    .attr(\"transform\", `translate(${margin.left},${margin.top})`);\n\n  \u002F\u002F Create scales\n  const xScale = d3.scaleBand()\n    .domain(columns)\n    .range([0, innerWidth])\n    .padding(0.01);\n\n  const yScale = d3.scaleBand()\n    .domain(rows)\n    .range([0, innerHeight])\n    .padding(0.01);\n\n  \u002F\u002F Colour scale for values\n  const colourScale = d3.scaleSequential(d3.interpolateYlOrRd)\n    .domain([0, d3.max(data, d => d.value)]);\n\n  \u002F\u002F Draw rectangles\n  g.selectAll(\"rect\")\n    .data(data)\n    .join(\"rect\")\n    .attr(\"x\", d => xScale(d.column))\n    .attr(\"y\", d => yScale(d.row))\n    .attr(\"width\", xScale.bandwidth())\n    .attr(\"height\", yScale.bandwidth())\n    .attr(\"fill\", d => colourScale(d.value));\n\n  \u002F\u002F Add x-axis labels\n  svg.append(\"g\")\n    .attr(\"transform\", `translate(${margin.left},${margin.top})`)\n    .selectAll(\"text\")\n    .data(columns)\n    .join(\"text\")\n    .attr(\"x\", d => xScale(d) + xScale.bandwidth() \u002F 2)\n    .attr(\"y\", -10)\n    .attr(\"text-anchor\", \"middle\")\n    .text(d => d)\n    .style(\"font-size\", \"12px\");\n\n  \u002F\u002F Add y-axis labels\n  svg.append(\"g\")\n    .attr(\"transform\", `translate(${margin.left},${margin.top})`)\n    .selectAll(\"text\")\n    .data(rows)\n    .join(\"text\")\n    .attr(\"x\", -10)\n    .attr(\"y\", d => yScale(d) + yScale.bandwidth() \u002F 2)\n    .attr(\"dy\", \"0.35em\")\n    .attr(\"text-anchor\", \"end\")\n    .text(d => d)\n    .style(\"font-size\", \"12px\");\n\n  \u002F\u002F Add colour legend\n  const legendWidth = 20;\n  const legendHeight = 200;\n  const legend = svg.append(\"g\")\n    .attr(\"transform\", `translate(${width - 60},${margin.top})`);\n\n  const legendScale = d3.scaleLinear()\n    .domain(colourScale.domain())\n    .range([legendHeight, 0]);\n\n  const legendAxis = d3.axisRight(legendScale)\n    .ticks(5);\n\n  \u002F\u002F Draw colour gradient in legend\n  for (let i = 0; i \u003C legendHeight; i++) {\n    legend.append(\"rect\")\n      .attr(\"y\", i)\n      .attr(\"width\", legendWidth)\n      .attr(\"height\", 1)\n      .attr(\"fill\", colourScale(legendScale.invert(i)));\n  }\n\n  legend.append(\"g\")\n    .attr(\"transform\", `translate(${legendWidth},0)`)\n    .call(legendAxis);\n}\n```\n\n### Pie chart\n\n```javascript\nconst pie = d3.pie()\n  .value(d => d.value)\n  .sort(null);\n\nconst arc = d3.arc()\n  .innerRadius(0)\n  .outerRadius(Math.min(width, height) \u002F 2 - 20);\n\nconst colourScale = d3.scaleOrdinal(d3.schemeCategory10);\n\nconst g = svg.append(\"g\")\n  .attr(\"transform\", `translate(${width \u002F 2},${height \u002F 2})`);\n\ng.selectAll(\"path\")\n  .data(pie(data))\n  .join(\"path\")\n  .attr(\"d\", arc)\n  .attr(\"fill\", (d, i) => colourScale(i))\n  .attr(\"stroke\", \"white\")\n  .attr(\"stroke-width\", 2);\n```\n\n### Force-directed network\n\n```javascript\nconst simulation = d3.forceSimulation(nodes)\n  .force(\"link\", d3.forceLink(links).id(d => d.id).distance(100))\n  .force(\"charge\", d3.forceManyBody().strength(-300))\n  .force(\"center\", d3.forceCenter(width \u002F 2, height \u002F 2));\n\nconst link = g.selectAll(\"line\")\n  .data(links)\n  .join(\"line\")\n  .attr(\"stroke\", \"#999\")\n  .attr(\"stroke-width\", 1);\n\nconst node = g.selectAll(\"circle\")\n  .data(nodes)\n  .join(\"circle\")\n  .attr(\"r\", 8)\n  .attr(\"fill\", \"steelblue\")\n  .call(d3.drag()\n    .on(\"start\", dragstarted)\n    .on(\"drag\", dragged)\n    .on(\"end\", dragended));\n\nsimulation.on(\"tick\", () => {\n  link\n    .attr(\"x1\", d => d.source.x)\n    .attr(\"y1\", d => d.source.y)\n    .attr(\"x2\", d => d.target.x)\n    .attr(\"y2\", d => d.target.y);\n  \n  node\n    .attr(\"cx\", d => d.x)\n    .attr(\"cy\", d => d.y);\n});\n\nfunction dragstarted(event) {\n  if (!event.active) simulation.alphaTarget(0.3).restart();\n  event.subject.fx = event.subject.x;\n  event.subject.fy = event.subject.y;\n}\n\nfunction dragged(event) {\n  event.subject.fx = event.x;\n  event.subject.fy = event.y;\n}\n\nfunction dragended(event) {\n  if (!event.active) simulation.alphaTarget(0);\n  event.subject.fx = null;\n  event.subject.fy = null;\n}\n```\n\n## Adding interactivity\n\n### Tooltips\n\n```javascript\n\u002F\u002F Create tooltip div (outside SVG)\nconst tooltip = d3.select(\"body\").append(\"div\")\n  .attr(\"class\", \"tooltip\")\n  .style(\"position\", \"absolute\")\n  .style(\"visibility\", \"hidden\")\n  .style(\"background-color\", \"white\")\n  .style(\"border\", \"1px solid #ddd\")\n  .style(\"padding\", \"10px\")\n  .style(\"border-radius\", \"4px\")\n  .style(\"pointer-events\", \"none\");\n\n\u002F\u002F Add to elements\ncircles\n  .on(\"mouseover\", function(event, d) {\n    d3.select(this).attr(\"opacity\", 1);\n    tooltip\n      .style(\"visibility\", \"visible\")\n      .html(`\u003Cstrong>${d.label}\u003C\u002Fstrong>\u003Cbr\u002F>Value: ${d.value}`);\n  })\n  .on(\"mousemove\", function(event) {\n    tooltip\n      .style(\"top\", (event.pageY - 10) + \"px\")\n      .style(\"left\", (event.pageX + 10) + \"px\");\n  })\n  .on(\"mouseout\", function() {\n    d3.select(this).attr(\"opacity\", 0.7);\n    tooltip.style(\"visibility\", \"hidden\");\n  });\n```\n\n### Zoom and pan\n\n```javascript\nconst zoom = d3.zoom()\n  .scaleExtent([0.5, 10])\n  .on(\"zoom\", (event) => {\n    g.attr(\"transform\", event.transform);\n  });\n\nsvg.call(zoom);\n```\n\n### Click interactions\n\n```javascript\ncircles\n  .on(\"click\", function(event, d) {\n    \u002F\u002F Handle click (dispatch event, update app state, etc.)\n    console.log(\"Clicked:\", d);\n\n    \u002F\u002F Visual feedback\n    d3.selectAll(\"circle\").attr(\"fill\", \"steelblue\");\n    d3.select(this).attr(\"fill\", \"orange\");\n\n    \u002F\u002F Optional: dispatch custom event for your framework\u002Fapp to listen to\n    \u002F\u002F window.dispatchEvent(new CustomEvent('chartClick', { detail: d }));\n  });\n```\n\n## Transitions and animations\n\nAdd smooth transitions to visual changes:\n\n```javascript\n\u002F\u002F Basic transition\ncircles\n  .transition()\n  .duration(750)\n  .attr(\"r\", 10);\n\n\u002F\u002F Chained transitions\ncircles\n  .transition()\n  .duration(500)\n  .attr(\"fill\", \"orange\")\n  .transition()\n  .duration(500)\n  .attr(\"r\", 15);\n\n\u002F\u002F Staggered transitions\ncircles\n  .transition()\n  .delay((d, i) => i * 50)\n  .duration(500)\n  .attr(\"cy\", d => yScale(d.value));\n\n\u002F\u002F Custom easing\ncircles\n  .transition()\n  .duration(1000)\n  .ease(d3.easeBounceOut)\n  .attr(\"r\", 10);\n```\n\n## Scales reference\n\n### Quantitative scales\n\n```javascript\n\u002F\u002F Linear scale\nconst xScale = d3.scaleLinear()\n  .domain([0, 100])\n  .range([0, 500]);\n\n\u002F\u002F Log scale (for exponential data)\nconst logScale = d3.scaleLog()\n  .domain([1, 1000])\n  .range([0, 500]);\n\n\u002F\u002F Power scale\nconst powScale = d3.scalePow()\n  .exponent(2)\n  .domain([0, 100])\n  .range([0, 500]);\n\n\u002F\u002F Time scale\nconst timeScale = d3.scaleTime()\n  .domain([new Date(2020, 0, 1), new Date(2024, 0, 1)])\n  .range([0, 500]);\n```\n\n### Ordinal scales\n\n```javascript\n\u002F\u002F Band scale (for bar charts)\nconst bandScale = d3.scaleBand()\n  .domain(['A', 'B', 'C', 'D'])\n  .range([0, 400])\n  .padding(0.1);\n\n\u002F\u002F Point scale (for line\u002Fscatter categories)\nconst pointScale = d3.scalePoint()\n  .domain(['A', 'B', 'C', 'D'])\n  .range([0, 400]);\n\n\u002F\u002F Ordinal scale (for colours)\nconst colourScale = d3.scaleOrdinal(d3.schemeCategory10);\n```\n\n### Sequential scales\n\n```javascript\n\u002F\u002F Sequential colour scale\nconst colourScale = d3.scaleSequential(d3.interpolateBlues)\n  .domain([0, 100]);\n\n\u002F\u002F Diverging colour scale\nconst divScale = d3.scaleDiverging(d3.interpolateRdBu)\n  .domain([-10, 0, 10]);\n```\n\n## Best practices\n\n### Data preparation\n\nAlways validate and prepare data before visualisation:\n\n```javascript\n\u002F\u002F Filter invalid values\nconst cleanData = data.filter(d => d.value != null && !isNaN(d.value));\n\n\u002F\u002F Sort data if order matters\nconst sortedData = [...data].sort((a, b) => b.value - a.value);\n\n\u002F\u002F Parse dates\nconst parsedData = data.map(d => ({\n  ...d,\n  date: d3.timeParse(\"%Y-%m-%d\")(d.date)\n}));\n```\n\n### Performance optimisation\n\nFor large datasets (>1000 elements):\n\n```javascript\n\u002F\u002F Use canvas instead of SVG for many elements\n\u002F\u002F Use quadtree for collision detection\n\u002F\u002F Simplify paths with d3.line().curve(d3.curveStep)\n\u002F\u002F Implement virtual scrolling for large lists\n\u002F\u002F Use requestAnimationFrame for custom animations\n```\n\n### Accessibility\n\nMake visualisations accessible:\n\n```javascript\n\u002F\u002F Add ARIA labels\nsvg.attr(\"role\", \"img\")\n   .attr(\"aria-label\", \"Bar chart showing quarterly revenue\");\n\n\u002F\u002F Add title and description\nsvg.append(\"title\").text(\"Quarterly Revenue 2024\");\nsvg.append(\"desc\").text(\"Bar chart showing revenue growth across four quarters\");\n\n\u002F\u002F Ensure sufficient colour contrast\n\u002F\u002F Provide keyboard navigation for interactive elements\n\u002F\u002F Include data table alternative\n```\n\n### Styling\n\nUse consistent, professional styling:\n\n```javascript\n\u002F\u002F Define colour palettes upfront\nconst colours = {\n  primary: '#4A90E2',\n  secondary: '#7B68EE',\n  background: '#F5F7FA',\n  text: '#333333',\n  gridLines: '#E0E0E0'\n};\n\n\u002F\u002F Apply consistent typography\nsvg.selectAll(\"text\")\n  .style(\"font-family\", \"Inter, sans-serif\")\n  .style(\"font-size\", \"12px\");\n\n\u002F\u002F Use subtle grid lines\ng.selectAll(\".tick line\")\n  .attr(\"stroke\", colours.gridLines)\n  .attr(\"stroke-dasharray\", \"2,2\");\n```\n\n## Common issues and solutions\n\n**Issue**: Axes not appearing\n- Ensure scales have valid domains (check for NaN values)\n- Verify axis is appended to correct group\n- Check transform translations are correct\n\n**Issue**: Transitions not working\n- Call `.transition()` before attribute changes\n- Ensure elements have unique keys for proper data binding\n- Check that useEffect dependencies include all changing data\n\n**Issue**: Responsive sizing not working\n- Use ResizeObserver or window resize listener\n- Update dimensions in state to trigger re-render\n- Ensure SVG has width\u002Fheight attributes or viewBox\n\n**Issue**: Performance problems\n- Limit number of DOM elements (consider canvas for >1000 items)\n- Debounce resize handlers\n- Use `.join()` instead of separate enter\u002Fupdate\u002Fexit selections\n- Avoid unnecessary re-renders by checking dependencies\n\n## Resources\n\n### references\u002F\nContains detailed reference materials:\n- `d3-patterns.md` - Comprehensive collection of visualisation patterns and code examples\n- `scale-reference.md` - Complete guide to d3 scales with examples\n- `colour-schemes.md` - D3 colour schemes and palette recommendations\n\n### assets\u002F\n\nContains boilerplate templates:\n\n- `chart-template.js` - Starter template for basic chart\n- `interactive-template.js` - Template with tooltips, zoom, and interactions\n- `sample-data.json` - Example datasets for testing\n\nThese templates work with vanilla JavaScript, React, Vue, Svelte, or any other JavaScript environment. Adapt them as needed for your specific framework.\n\nTo use these resources, read the relevant files when detailed guidance is needed for specific visualisation types or patterns.\n","# D3.js Visualisation\n\n## Overview\n\nThis skill provides guidance for creating sophisticated, interactive data visualisations using d3.js. D3.js (Data-Driven Documents) excels at binding data to DOM elements and applying data-driven transformations to create custom, publication-quality visualisations with precise control over every visual element. The techniques work across any JavaScript environment, including vanilla JavaScript, React, Vue, Svelte, and other frameworks.\n\n## When to use d3.js\n\n**Use d3.js for:**\n- Custom visualisations requiring unique visual encodings or layouts\n- Interactive explorations with complex pan, zoom, or brush behaviours\n- Network\u002Fgraph visualisations (force-directed layouts, tree diagrams, hierarchies, chord diagrams)\n- Geographic visualisations with custom projections\n- Visualisations requiring smooth, choreographed transitions\n- Publication-quality graphics with fine-grained styling control\n- Novel chart types not available in standard libraries\n\n**Consider alternatives for:**\n- 3D visualisations - use Three.js instead\n\n## Core workflow\n\n### 1. Set up d3.js\n\nImport d3 at the top of your script:\n\n```javascript\nimport * as d3 from 'd3';\n```\n\nOr use the CDN version (7.x):\n\n```html\n\u003Cscript src=\"https:\u002F\u002Fd3js.org\u002Fd3.v7.min.js\">\u003C\u002Fscript>\n```\n\nAll modules (scales, axes, shapes, transitions, etc.) are accessible through the `d3` namespace.\n\n### 2. Choose the integration pattern\n\n**Pattern A: Direct DOM manipulation (recommended for most cases)**\nUse d3 to select DOM elements and manipulate them imperatively. This works in any JavaScript environment:\n\n```javascript\nfunction drawChart(data) {\n  if (!data || data.length === 0) return;\n\n  const svg = d3.select('#chart'); \u002F\u002F Select by ID, class, or DOM element\n\n  \u002F\u002F Clear previous content\n  svg.selectAll(\"*\").remove();\n\n  \u002F\u002F Set up dimensions\n  const width = 800;\n  const height = 400;\n  const margin = { top: 20, right: 30, bottom: 40, left: 50 };\n\n  \u002F\u002F Create scales, axes, and draw visualisation\n  \u002F\u002F ... d3 code here ...\n}\n\n\u002F\u002F Call when data changes\ndrawChart(myData);\n```\n\n**Pattern B: Declarative rendering (for frameworks with templating)**\nUse d3 for data calculations (scales, layouts) but render elements via your framework:\n\n```javascript\nfunction getChartElements(data) {\n  const xScale = d3.scaleLinear()\n    .domain([0, d3.max(data, d => d.value)])\n    .range([0, 400]);\n\n  return data.map((d, i) => ({\n    x: 50,\n    y: i * 30,\n    width: xScale(d.value),\n    height: 25\n  }));\n}\n\n\u002F\u002F In React: {getChartElements(data).map((d, i) => \u003Crect key={i} {...d} fill=\"steelblue\" \u002F>)}\n\u002F\u002F In Vue: v-for directive over the returned array\n\u002F\u002F In vanilla JS: Create elements manually from the returned data\n```\n\nUse Pattern A for complex visualisations with transitions, interactions, or when leveraging d3's full capabilities. Use Pattern B for simpler visualisations or when your framework prefers declarative rendering.\n\n### 3. Structure the visualisation code\n\nFollow this standard structure in your drawing function:\n\n```javascript\nfunction drawVisualization(data) {\n  if (!data || data.length === 0) return;\n\n  const svg = d3.select('#chart'); \u002F\u002F Or pass a selector\u002Felement\n  svg.selectAll(\"*\").remove(); \u002F\u002F Clear previous render\n\n  \u002F\u002F 1. Define dimensions\n  const width = 800;\n  const height = 400;\n  const margin = { top: 20, right: 30, bottom: 40, left: 50 };\n  const innerWidth = width - margin.left - margin.right;\n  const innerHeight = height - margin.top - margin.bottom;\n\n  \u002F\u002F 2. Create main group with margins\n  const g = svg.append(\"g\")\n    .attr(\"transform\", `translate(${margin.left},${margin.top})`);\n\n  \u002F\u002F 3. Create scales\n  const xScale = d3.scaleLinear()\n    .domain([0, d3.max(data, d => d.x)])\n    .range([0, innerWidth]);\n\n  const yScale = d3.scaleLinear()\n    .domain([0, d3.max(data, d => d.y)])\n    .range([innerHeight, 0]); \u002F\u002F Note: inverted for SVG coordinates\n\n  \u002F\u002F 4. Create and append axes\n  const xAxis = d3.axisBottom(xScale);\n  const yAxis = d3.axisLeft(yScale);\n\n  g.append(\"g\")\n    .attr(\"transform\", `translate(0,${innerHeight})`)\n    .call(xAxis);\n\n  g.append(\"g\")\n    .call(yAxis);\n\n  \u002F\u002F 5. Bind data and create visual elements\n  g.selectAll(\"circle\")\n    .data(data)\n    .join(\"circle\")\n    .attr(\"cx\", d => xScale(d.x))\n    .attr(\"cy\", d => yScale(d.y))\n    .attr(\"r\", 5)\n    .attr(\"fill\", \"steelblue\");\n}\n\n\u002F\u002F Call when data changes\ndrawVisualization(myData);\n```\n\n### 4. Implement responsive sizing\n\nMake visualisations responsive to container size:\n\n```javascript\nfunction setupResponsiveChart(containerId, data) {\n  const container = document.getElementById(containerId);\n  const svg = d3.select(`#${containerId}`).append('svg');\n\n  function updateChart() {\n    const { width, height } = container.getBoundingClientRect();\n    svg.attr('width', width).attr('height', height);\n\n    \u002F\u002F Redraw visualisation with new dimensions\n    drawChart(data, svg, width, height);\n  }\n\n  \u002F\u002F Update on initial load\n  updateChart();\n\n  \u002F\u002F Update on window resize\n  window.addEventListener('resize', updateChart);\n\n  \u002F\u002F Return cleanup function\n  return () => window.removeEventListener('resize', updateChart);\n}\n\n\u002F\u002F Usage:\n\u002F\u002F const cleanup = setupResponsiveChart('chart-container', myData);\n\u002F\u002F cleanup(); \u002F\u002F Call when component unmounts or element removed\n```\n\nOr use ResizeObserver for more direct container monitoring:\n\n```javascript\nfunction setupResponsiveChartWithObserver(svgElement, data) {\n  const observer = new ResizeObserver(() => {\n    const { width, height } = svgElement.getBoundingClientRect();\n    d3.select(svgElement)\n      .attr('width', width)\n      .attr('height', height);\n\n    \u002F\u002F Redraw visualisation\n    drawChart(data, d3.select(svgElement), width, height);\n  });\n\n  observer.observe(svgElement.parentElement);\n  return () => observer.disconnect();\n}\n```\n\n## Common visualisation patterns\n\n### Bar chart\n\n```javascript\nfunction drawBarChart(data, svgElement) {\n  if (!data || data.length === 0) return;\n\n  const svg = d3.select(svgElement);\n  svg.selectAll(\"*\").remove();\n\n  const width = 800;\n  const height = 400;\n  const margin = { top: 20, right: 30, bottom: 40, left: 50 };\n  const innerWidth = width - margin.left - margin.right;\n  const innerHeight = height - margin.top - margin.bottom;\n\n  const g = svg.append(\"g\")\n    .attr(\"transform\", `translate(${margin.left},${margin.top})`);\n\n  const xScale = d3.scaleBand()\n    .domain(data.map(d => d.category))\n    .range([0, innerWidth])\n    .padding(0.1);\n\n  const yScale = d3.scaleLinear()\n    .domain([0, d3.max(data, d => d.value)])\n    .range([innerHeight, 0]);\n\n  g.append(\"g\")\n    .attr(\"transform\", `translate(0,${innerHeight})`)\n    .call(d3.axisBottom(xScale));\n\n  g.append(\"g\")\n    .call(d3.axisLeft(yScale));\n\n  g.selectAll(\"rect\")\n    .data(data)\n    .join(\"rect\")\n    .attr(\"x\", d => xScale(d.category))\n    .attr(\"y\", d => yScale(d.value))\n    .attr(\"width\", xScale.bandwidth())\n    .attr(\"height\", d => innerHeight - yScale(d.value))\n    .attr(\"fill\", \"steelblue\");\n}\n\n\u002F\u002F Usage:\n\u002F\u002F drawBarChart(myData, document.getElementById('chart'));\n```\n\n### Line chart\n\n```javascript\nconst line = d3.line()\n  .x(d => xScale(d.date))\n  .y(d => yScale(d.value))\n  .curve(d3.curveMonotoneX); \u002F\u002F Smooth curve\n\ng.append(\"path\")\n  .datum(data)\n  .attr(\"fill\", \"none\")\n  .attr(\"stroke\", \"steelblue\")\n  .attr(\"stroke-width\", 2)\n  .attr(\"d\", line);\n```\n\n### Scatter plot\n\n```javascript\ng.selectAll(\"circle\")\n  .data(data)\n  .join(\"circle\")\n  .attr(\"cx\", d => xScale(d.x))\n  .attr(\"cy\", d => yScale(d.y))\n  .attr(\"r\", d => sizeScale(d.size)) \u002F\u002F Optional: size encoding\n  .attr(\"fill\", d => colourScale(d.category)) \u002F\u002F Optional: colour encoding\n  .attr(\"opacity\", 0.7);\n```\n\n### Chord diagram\n\nA chord diagram shows relationships between entities in a circular layout, with ribbons representing flows between them:\n\n```javascript\nfunction drawChordDiagram(data) {\n  \u002F\u002F data format: array of objects with source, target, and value\n  \u002F\u002F Example: [{ source: 'A', target: 'B', value: 10 }, ...]\n\n  if (!data || data.length === 0) return;\n\n  const svg = d3.select('#chart');\n  svg.selectAll(\"*\").remove();\n\n  const width = 600;\n  const height = 600;\n  const innerRadius = Math.min(width, height) * 0.3;\n  const outerRadius = innerRadius + 30;\n\n  \u002F\u002F Create matrix from data\n  const nodes = Array.from(new Set(data.flatMap(d => [d.source, d.target])));\n  const matrix = Array.from({ length: nodes.length }, () => Array(nodes.length).fill(0));\n\n  data.forEach(d => {\n    const i = nodes.indexOf(d.source);\n    const j = nodes.indexOf(d.target);\n    matrix[i][j] += d.value;\n    matrix[j][i] += d.value;\n  });\n\n  \u002F\u002F Create chord layout\n  const chord = d3.chord()\n    .padAngle(0.05)\n    .sortSubgroups(d3.descending);\n\n  const arc = d3.arc()\n    .innerRadius(innerRadius)\n    .outerRadius(outerRadius);\n\n  const ribbon = d3.ribbon()\n    .source(d => d.source)\n    .target(d => d.target);\n\n  const colourScale = d3.scaleOrdinal(d3.schemeCategory10)\n    .domain(nodes);\n\n  const g = svg.append(\"g\")\n    .attr(\"transform\", `translate(${width \u002F 2},${height \u002F 2})`);\n\n  const chords = chord(matrix);\n\n  \u002F\u002F Draw ribbons\n  g.append(\"g\")\n    .attr(\"fill-opacity\", 0.67)\n    .selectAll(\"path\")\n    .data(chords)\n    .join(\"path\")\n    .attr(\"d\", ribbon)\n    .attr(\"fill\", d => colourScale(nodes[d.source.index]))\n    .attr(\"stroke\", d => d3.rgb(colourScale(nodes[d.source.index])).darker());\n\n  \u002F\u002F Draw groups (arcs)\n  const group = g.append(\"g\")\n    .selectAll(\"g\")\n    .data(chords.groups)\n    .join(\"g\");\n\n  group.append(\"path\")\n    .attr(\"d\", arc)\n    .attr(\"fill\", d => colourScale(nodes[d.index]))\n    .attr(\"stroke\", d => d3.rgb(colourScale(nodes[d.index])).darker());\n\n  \u002F\u002F Add labels\n  group.append(\"text\")\n    .each(d => { d.angle = (d.startAngle + d.endAngle) \u002F 2; })\n    .attr(\"dy\", \"0.31em\")\n    .attr(\"transform\", d => `rotate(${(d.angle * 180 \u002F Math.PI) - 90})translate(${outerRadius + 30})${d.angle > Math.PI ? \"rotate(180)\" : \"\"}`)\n    .attr(\"text-anchor\", d => d.angle > Math.PI ? \"end\" : null)\n    .text((d, i) => nodes[i])\n    .style(\"font-size\", \"12px\");\n}\n```\n\n### Heatmap\n\nA heatmap uses colour to encode values in a two-dimensional grid, useful for showing patterns across categories:\n\n```javascript\nfunction drawHeatmap(data) {\n  \u002F\u002F data format: array of objects with row, column, and value\n  \u002F\u002F Example: [{ row: 'A', column: 'X', value: 10 }, ...]\n\n  if (!data || data.length === 0) return;\n\n  const svg = d3.select('#chart');\n  svg.selectAll(\"*\").remove();\n\n  const width = 800;\n  const height = 600;\n  const margin = { top: 100, right: 30, bottom: 30, left: 100 };\n  const innerWidth = width - margin.left - margin.right;\n  const innerHeight = height - margin.top - margin.bottom;\n\n  \u002F\u002F Get unique rows and columns\n  const rows = Array.from(new Set(data.map(d => d.row)));\n  const columns = Array.from(new Set(data.map(d => d.column)));\n\n  const g = svg.append(\"g\")\n    .attr(\"transform\", `translate(${margin.left},${margin.top})`);\n\n  \u002F\u002F Create scales\n  const xScale = d3.scaleBand()\n    .domain(columns)\n    .range([0, innerWidth])\n    .padding(0.01);\n\n  const yScale = d3.scaleBand()\n    .domain(rows)\n    .range([0, innerHeight])\n    .padding(0.01);\n\n  \u002F\u002F Colour scale for values\n  const colourScale = d3.scaleSequential(d3.interpolateYlOrRd)\n    .domain([0, d3.max(data, d => d.value)]);\n\n  \u002F\u002F Draw rectangles\n  g.selectAll(\"rect\")\n    .data(data)\n    .join(\"rect\")\n    .attr(\"x\", d => xScale(d.column))\n    .attr(\"y\", d => yScale(d.row))\n    .attr(\"width\", xScale.bandwidth())\n    .attr(\"height\", yScale.bandwidth())\n    .attr(\"fill\", d => colourScale(d.value));\n\n  \u002F\u002F Add x-axis labels\n  svg.append(\"g\")\n    .attr(\"transform\", `translate(${margin.left},${margin.top})`)\n    .selectAll(\"text\")\n    .data(columns)\n    .join(\"text\")\n    .attr(\"x\", d => xScale(d) + xScale.bandwidth() \u002F 2)\n    .attr(\"y\", -10)\n    .attr(\"text-anchor\", \"middle\")\n    .text(d => d)\n    .style(\"font-size\", \"12px\");\n\n  \u002F\u002F Add y-axis labels\n  svg.append(\"g\")\n    .attr(\"transform\", `translate(${margin.left},${margin.top})`)\n    .selectAll(\"text\")\n    .data(rows)\n    .join(\"text\")\n    .attr(\"x\", -10)\n    .attr(\"y\", d => yScale(d) + yScale.bandwidth() \u002F 2)\n    .attr(\"dy\", \"0.35em\")\n    .attr(\"text-anchor\", \"end\")\n    .text(d => d)\n    .style(\"font-size\", \"12px\");\n\n  \u002F\u002F Add colour legend\n  const legendWidth = 20;\n  const legendHeight = 200;\n  const legend = svg.append(\"g\")\n    .attr(\"transform\", `translate(${width - 60},${margin.top})`);\n\n  const legendScale = d3.scaleLinear()\n    .domain(colourScale.domain())\n    .range([legendHeight, 0]);\n\n  const legendAxis = d3.axisRight(legendScale)\n    .ticks(5);\n\n  \u002F\u002F Draw colour gradient in legend\n  for (let i = 0; i \u003C legendHeight; i++) {\n    legend.append(\"rect\")\n      .attr(\"y\", i)\n      .attr(\"width\", legendWidth)\n      .attr(\"height\", 1)\n      .attr(\"fill\", colourScale(legendScale.invert(i)));\n  }\n\n  legend.append(\"g\")\n    .attr(\"transform\", `translate(${legendWidth},0)`)\n    .call(legendAxis);\n}\n```\n\n### Pie chart\n\n```javascript\nconst pie = d3.pie()\n  .value(d => d.value)\n  .sort(null);\n\nconst arc = d3.arc()\n  .innerRadius(0)\n  .outerRadius(Math.min(width, height) \u002F 2 - 20);\n\nconst colourScale = d3.scaleOrdinal(d3.schemeCategory10);\n\nconst g = svg.append(\"g\")\n  .attr(\"transform\", `translate(${width \u002F 2},${height \u002F 2})`);\n\ng.selectAll(\"path\")\n  .data(pie(data))\n  .join(\"path\")\n  .attr(\"d\", arc)\n  .attr(\"fill\", (d, i) => colourScale(i))\n  .attr(\"stroke\", \"white\")\n  .attr(\"stroke-width\", 2);\n```\n\n### Force-directed network\n\n```javascript\nconst simulation = d3.forceSimulation(nodes)\n  .force(\"link\", d3.forceLink(links).id(d => d.id).distance(100))\n  .force(\"charge\", d3.forceManyBody().strength(-300))\n  .force(\"center\", d3.forceCenter(width \u002F 2, height \u002F 2));\n\nconst link = g.selectAll(\"line\")\n  .data(links)\n  .join(\"line\")\n  .attr(\"stroke\", \"#999\")\n  .attr(\"stroke-width\", 1);\n\nconst node = g.selectAll(\"circle\")\n  .data(nodes)\n  .join(\"circle\")\n  .attr(\"r\", 8)\n  .attr(\"fill\", \"steelblue\")\n  .call(d3.drag()\n    .on(\"start\", dragstarted)\n    .on(\"drag\", dragged)\n    .on(\"end\", dragended));\n\nsimulation.on(\"tick\", () => {\n  link\n    .attr(\"x1\", d => d.source.x)\n    .attr(\"y1\", d => d.source.y)\n    .attr(\"x2\", d => d.target.x)\n    .attr(\"y2\", d => d.target.y);\n  \n  node\n    .attr(\"cx\", d => d.x)\n    .attr(\"cy\", d => d.y);\n});\n\nfunction dragstarted(event) {\n  if (!event.active) simulation.alphaTarget(0.3).restart();\n  event.subject.fx = event.subject.x;\n  event.subject.fy = event.subject.y;\n}\n\nfunction dragged(event) {\n  event.subject.fx = event.x;\n  event.subject.fy = event.y;\n}\n\nfunction dragended(event) {\n  if (!event.active) simulation.alphaTarget(0);\n  event.subject.fx = null;\n  event.subject.fy = null;\n}\n```\n\n## Adding interactivity\n\n### Tooltips\n\n```javascript\n\u002F\u002F Create tooltip div (outside SVG)\nconst tooltip = d3.select(\"body\").append(\"div\")\n  .attr(\"class\", \"tooltip\")\n  .style(\"position\", \"absolute\")\n  .style(\"visibility\", \"hidden\")\n  .style(\"background-color\", \"white\")\n  .style(\"border\", \"1px solid #ddd\")\n  .style(\"padding\", \"10px\")\n  .style(\"border-radius\", \"4px\")\n  .style(\"pointer-events\", \"none\");\n\n\u002F\u002F Add to elements\ncircles\n  .on(\"mouseover\", function(event, d) {\n    d3.select(this).attr(\"opacity\", 1);\n    tooltip\n      .style(\"visibility\", \"visible\")\n      .html(`\u003Cstrong>${d.label}\u003C\u002Fstrong>\u003Cbr\u002F>Value: ${d.value}`);\n  })\n  .on(\"mousemove\", function(event) {\n    tooltip\n      .style(\"top\", (event.pageY - 10) + \"px\")\n      .style(\"left\", (event.pageX + 10) + \"px\");\n  })\n  .on(\"mouseout\", function() {\n    d3.select(this).attr(\"opacity\", 0.7);\n    tooltip.style(\"visibility\", \"hidden\");\n  });\n```\n\n### Zoom and pan\n\n```javascript\nconst zoom = d3.zoom()\n  .scaleExtent([0.5, 10])\n  .on(\"zoom\", (event) => {\n    g.attr(\"transform\", event.transform);\n  });\n\nsvg.call(zoom);\n```\n\n### Click interactions\n\n```javascript\ncircles\n  .on(\"click\", function(event, d) {\n    \u002F\u002F Handle click (dispatch event, update app state, etc.)\n    console.log(\"Clicked:\", d);\n\n    \u002F\u002F Visual feedback\n    d3.selectAll(\"circle\").attr(\"fill\", \"steelblue\");\n    d3.select(this).attr(\"fill\", \"orange\");\n\n    \u002F\u002F Optional: dispatch custom event for your framework\u002Fapp to listen to\n    \u002F\u002F window.dispatchEvent(new CustomEvent('chartClick', { detail: d }));\n  });\n```\n\n## Transitions and animations\n\nAdd smooth transitions to visual changes:\n\n```javascript\n\u002F\u002F Basic transition\ncircles\n  .transition()\n  .duration(750)\n  .attr(\"r\", 10);\n\n\u002F\u002F Chained transitions\ncircles\n  .transition()\n  .duration(500)\n  .attr(\"fill\", \"orange\")\n  .transition()\n  .duration(500)\n  .attr(\"r\", 15);\n\n\u002F\u002F Staggered transitions\ncircles\n  .transition()\n  .delay((d, i) => i * 50)\n  .duration(500)\n  .attr(\"cy\", d => yScale(d.value));\n\n\u002F\u002F Custom easing\ncircles\n  .transition()\n  .duration(1000)\n  .ease(d3.easeBounceOut)\n  .attr(\"r\", 10);\n```\n\n## Scales reference\n\n### Quantitative scales\n\n```javascript\n\u002F\u002F Linear scale\nconst xScale = d3.scaleLinear()\n  .domain([0, 100])\n  .range([0, 500]);\n\n\u002F\u002F Log scale (for exponential data)\nconst logScale = d3.scaleLog()\n  .domain([1, 1000])\n  .range([0, 500]);\n\n\u002F\u002F Power scale\nconst powScale = d3.scalePow()\n  .exponent(2)\n  .domain([0, 100])\n  .range([0, 500]);\n\n\u002F\u002F Time scale\nconst timeScale = d3.scaleTime()\n  .domain([new Date(2020, 0, 1), new Date(2024, 0, 1)])\n  .range([0, 500]);\n```\n\n### Ordinal scales\n\n```javascript\n\u002F\u002F Band scale (for bar charts)\nconst bandScale = d3.scaleBand()\n  .domain(['A', 'B', 'C', 'D'])\n  .range([0, 400])\n  .padding(0.1);\n\n\u002F\u002F Point scale (for line\u002Fscatter categories)\nconst pointScale = d3.scalePoint()\n  .domain(['A', 'B', 'C', 'D'])\n  .range([0, 400]);\n\n\u002F\u002F Ordinal scale (for colours)\nconst colourScale = d3.scaleOrdinal(d3.schemeCategory10);\n```\n\n### Sequential scales\n\n```javascript\n\u002F\u002F Sequential colour scale\nconst colourScale = d3.scaleSequential(d3.interpolateBlues)\n  .domain([0, 100]);\n\n\u002F\u002F Diverging colour scale\nconst divScale = d3.scaleDiverging(d3.interpolateRdBu)\n  .domain([-10, 0, 10]);\n```\n\n## Best practices\n\n### Data preparation\n\nAlways validate and prepare data before visualisation:\n\n```javascript\n\u002F\u002F Filter invalid values\nconst cleanData = data.filter(d => d.value != null && !isNaN(d.value));\n\n\u002F\u002F Sort data if order matters\nconst sortedData = [...data].sort((a, b) => b.value - a.value);\n\n\u002F\u002F Parse dates\nconst parsedData = data.map(d => ({\n  ...d,\n  date: d3.timeParse(\"%Y-%m-%d\")(d.date)\n}));\n```\n\n### Performance optimisation\n\nFor large datasets (>1000 elements):\n\n```javascript\n\u002F\u002F Use canvas instead of SVG for many elements\n\u002F\u002F Use quadtree for collision detection\n\u002F\u002F Simplify paths with d3.line().curve(d3.curveStep)\n\u002F\u002F Implement virtual scrolling for large lists\n\u002F\u002F Use requestAnimationFrame for custom animations\n```\n\n### Accessibility\n\nMake visualisations accessible:\n\n```javascript\n\u002F\u002F Add ARIA labels\nsvg.attr(\"role\", \"img\")\n   .attr(\"aria-label\", \"Bar chart showing quarterly revenue\");\n\n\u002F\u002F Add title and description\nsvg.append(\"title\").text(\"Quarterly Revenue 2024\");\nsvg.append(\"desc\").text(\"Bar chart showing revenue growth across four quarters\");\n\n\u002F\u002F Ensure sufficient colour contrast\n\u002F\u002F Provide keyboard navigation for interactive elements\n\u002F\u002F Include data table alternative\n```\n\n### Styling\n\nUse consistent, professional styling:\n\n```javascript\n\u002F\u002F Define colour palettes upfront\nconst colours = {\n  primary: '#4A90E2',\n  secondary: '#7B68EE',\n  background: '#F5F7FA',\n  text: '#333333',\n  gridLines: '#E0E0E0'\n};\n\n\u002F\u002F Apply consistent typography\nsvg.selectAll(\"text\")\n  .style(\"font-family\", \"Inter, sans-serif\")\n  .style(\"font-size\", \"12px\");\n\n\u002F\u002F Use subtle grid lines\ng.selectAll(\".tick line\")\n  .attr(\"stroke\", colours.gridLines)\n  .attr(\"stroke-dasharray\", \"2,2\");\n```\n\n## Common issues and solutions\n\n**Issue**: Axes not appearing\n- Ensure scales have valid domains (check for NaN values)\n- Verify axis is appended to correct group\n- Check transform translations are correct\n\n**Issue**: Transitions not working\n- Call `.transition()` before attribute changes\n- Ensure elements have unique keys for proper data binding\n- Check that useEffect dependencies include all changing data\n\n**Issue**: Responsive sizing not working\n- Use ResizeObserver or window resize listener\n- Update dimensions in state to trigger re-render\n- Ensure SVG has width\u002Fheight attributes or viewBox\n\n**Issue**: Performance problems\n- Limit number of DOM elements (consider canvas for >1000 items)\n- Debounce resize handlers\n- Use `.join()` instead of separate enter\u002Fupdate\u002Fexit selections\n- Avoid unnecessary re-renders by checking dependencies\n\n## Resources\n\n### references\u002F\nContains detailed reference materials:\n- `d3-patterns.md` - Comprehensive collection of visualisation patterns and code examples\n- `scale-reference.md` - Complete guide to d3 scales with examples\n- `colour-schemes.md` - D3 colour schemes and palette recommendations\n\n### assets\u002F\n\nContains boilerplate templates:\n\n- `chart-template.js` - Starter template for basic chart\n- `interactive-template.js` - Template with tooltips, zoom, and interactions\n- `sample-data.json` - Example datasets for testing\n\nThese templates work with vanilla JavaScript, React, Vue, Svelte, or any other JavaScript environment. Adapt them as needed for your specific framework.\n\nTo use these resources, read the relevant files when detailed guidance is needed for specific visualisation types or patterns.\n",{"name":5,"description":7},"main","2b749c82b5d11fac39d9a6e021ce3f5b8a541bd1","cli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Fclaude-d3js-skill",3963,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates","https:\u002F\u002Faitmpl.com","https:\u002F\u002Fgithub.com\u002Fdavila7","https:\u002F\u002Fdanielavila.me","Building AI dev tools with LLMs","2026-11-15 01:32:48",{"source":9,"skillName":5,"commands":68,"prompt":78,"zipAvailable":79},[69,72,75],{"tool":70,"command":71},"npx","npx skills add davila7\u002Fclaude-code-templates --skill claude-d3js-skill",{"tool":73,"command":74},"bunx","bunx skills add davila7\u002Fclaude-code-templates --skill claude-d3js-skill",{"tool":76,"command":77},"pnpm","pnpm dlx skills add davila7\u002Fclaude-code-templates --skill claude-d3js-skill","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Fclaude-d3js-skill\u002FSKILL.md",true,[81,87,93,97,101,107,111,115,120,124,128,132,136,140,144,148,152,158,162,166,170,174,178,182,186,190],{"path":82,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":85,"sourceHtmlUrl":86},".gitignore","OTHER","其他",723,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002F.gitignore",{"path":88,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":91,"sourceHtmlUrl":92},"assets\u002Fchart-template.jsx","ASSET","资产文件",2820,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Fclaude-d3js-skill\u002Fassets\u002Fchart-template.jsx",{"path":94,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":95,"sourceHtmlUrl":96},"assets\u002Finteractive-template.jsx",6468,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Fclaude-d3js-skill\u002Fassets\u002Finteractive-template.jsx",{"path":98,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":99,"sourceHtmlUrl":100},"assets\u002Fsample-data.json",4480,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Fclaude-d3js-skill\u002Fassets\u002Fsample-data.json",{"path":102,"resourceType":103,"resourceTypeDesc":104,"sizeBytes":105,"sourceHtmlUrl":106},"AUTHENTICATION.md","REFERENCE","参考文档",5729,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002FAUTHENTICATION.md",{"path":108,"resourceType":103,"resourceTypeDesc":104,"sizeBytes":109,"sourceHtmlUrl":110},"CHANGELOG.md",1774,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002FCHANGELOG.md",{"path":112,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":113,"sourceHtmlUrl":114},"images\u002Fexample_notebookchat.png",137552,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Fimages\u002Fexample_notebookchat.png",{"path":116,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":118,"sourceHtmlUrl":119},"LICENSE","许可证",1072,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002FLICENSE",{"path":121,"resourceType":103,"resourceTypeDesc":104,"sizeBytes":122,"sourceHtmlUrl":123},"README.md",15901,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002FREADME.md",{"path":125,"resourceType":103,"resourceTypeDesc":104,"sizeBytes":126,"sourceHtmlUrl":127},"references\u002Fapi_reference.md",7630,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Freferences\u002Fapi_reference.md",{"path":129,"resourceType":103,"resourceTypeDesc":104,"sizeBytes":130,"sourceHtmlUrl":131},"references\u002Fcolour-schemes.md",12761,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Fclaude-d3js-skill\u002Freferences\u002Fcolour-schemes.md",{"path":133,"resourceType":103,"resourceTypeDesc":104,"sizeBytes":134,"sourceHtmlUrl":135},"references\u002Fd3-patterns.md",21605,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Fclaude-d3js-skill\u002Freferences\u002Fd3-patterns.md",{"path":137,"resourceType":103,"resourceTypeDesc":104,"sizeBytes":138,"sourceHtmlUrl":139},"references\u002Fscale-reference.md",12079,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Fclaude-d3js-skill\u002Freferences\u002Fscale-reference.md",{"path":141,"resourceType":103,"resourceTypeDesc":104,"sizeBytes":142,"sourceHtmlUrl":143},"references\u002Ftroubleshooting.md",8994,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Freferences\u002Ftroubleshooting.md",{"path":145,"resourceType":103,"resourceTypeDesc":104,"sizeBytes":146,"sourceHtmlUrl":147},"references\u002Fusage_patterns.md",9574,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Freferences\u002Fusage_patterns.md",{"path":149,"resourceType":103,"resourceTypeDesc":104,"sizeBytes":150,"sourceHtmlUrl":151},"requirements.txt",325,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Frequirements.txt",{"path":153,"resourceType":154,"resourceTypeDesc":155,"sizeBytes":156,"sourceHtmlUrl":157},"scripts\u002F__init__.py","SCRIPT","脚本",2627,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Fscripts\u002F__init__.py",{"path":159,"resourceType":154,"resourceTypeDesc":155,"sizeBytes":160,"sourceHtmlUrl":161},"scripts\u002Fask_question.py",8196,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Fscripts\u002Fask_question.py",{"path":163,"resourceType":154,"resourceTypeDesc":155,"sizeBytes":164,"sourceHtmlUrl":165},"scripts\u002Fauth_manager.py",11544,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Fscripts\u002Fauth_manager.py",{"path":167,"resourceType":154,"resourceTypeDesc":155,"sizeBytes":168,"sourceHtmlUrl":169},"scripts\u002Fbrowser_session.py",8725,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Fscripts\u002Fbrowser_session.py",{"path":171,"resourceType":154,"resourceTypeDesc":155,"sizeBytes":172,"sourceHtmlUrl":173},"scripts\u002Fbrowser_utils.py",3525,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Fscripts\u002Fbrowser_utils.py",{"path":175,"resourceType":154,"resourceTypeDesc":155,"sizeBytes":176,"sourceHtmlUrl":177},"scripts\u002Fcleanup_manager.py",9777,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Fscripts\u002Fcleanup_manager.py",{"path":179,"resourceType":154,"resourceTypeDesc":155,"sizeBytes":180,"sourceHtmlUrl":181},"scripts\u002Fconfig.py",1228,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Fscripts\u002Fconfig.py",{"path":183,"resourceType":154,"resourceTypeDesc":155,"sizeBytes":184,"sourceHtmlUrl":185},"scripts\u002Fnotebook_manager.py",13843,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Fscripts\u002Fnotebook_manager.py",{"path":187,"resourceType":154,"resourceTypeDesc":155,"sizeBytes":188,"sourceHtmlUrl":189},"scripts\u002Frun.py",2967,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Fscripts\u002Frun.py",{"path":191,"resourceType":154,"resourceTypeDesc":155,"sizeBytes":192,"sourceHtmlUrl":193},"scripts\u002Fsetup_environment.py",7168,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002Fscripts\u002Fsetup_environment.py",[195,219,245,269,308,336],{"skillNo":196,"name":197,"nameZh":17,"description":198,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":199,"categories":200,"keywords":201,"publishedAt":52},"01M70NHBTQ8BV0A2SCAZXEPHCX","wealthville-pool-scoring","Score DeFi liquidity pools before providing liquidity. Returns a 0-100 pool score and an Enter\u002FHold\u002FExit\u002FReduce\u002FAvoid verdict with calibrated confidence for ~68,800 Solana pools and 575 EVM pools, plus a public miss-inclusive track record. Use when asked whether a pool is worth LPing into, which pools look best right now, or how accurate the scores have actually been.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fweb-data\u002Fwealthville-pool-scoring\u002FSKILL.md",[],[202,203,204,205,206,36,207,208,33,34,209,210,211,212,213,214,215,216,217,218],"scoring","pool","wealthville pool scoring","liquidity","which","exit","now","reduce","with","record","track","verdict","evm","solana","how","public","look",{"skillNo":220,"name":221,"nameZh":17,"description":222,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":223,"categories":224,"keywords":225,"publishedAt":52},"01M70MB6VR8ERJ4EM8D5KHBMEV","technical-debt-auditor","Scans a codebase and produces a quantified technical debt report with a prioritized remediation plan. Analyzes dead code, TODO\u002FFIXME\u002FHACK markers, dependency staleness, complexity hotspots, code duplication signals, test coverage gaps, unused exports, and outdated patterns. Use this skill when the user asks to audit their codebase for tech debt, wants a health check of their code quality, says things like \"where should I focus refactoring\", \"find code smells\", \"audit my codebase\", \"what technical debt do we have\", \"prioritize cleanup work\", or asks about code quality metrics. Also trigger when the user mentions \"code rot\", \"legacy cleanup\", \"refactoring priorities\", or wants to understand the overall health of a project before a major effort. Trigger even if the user doesn't say \"technical debt\" explicitly — any request to systematically assess code quality and identify improvement priorities belongs here.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fdevelopment\u002Ftechnical-debt-auditor\u002FSKILL.md",[],[226,227,228,229,230,231,232,233,234,235,236,34,237,238,239,240,241,242,243,244],"technical debt","debt","technical","technical debt auditor","auditor","coverage","complexity","markers","project","cleanup","unused","code","todo","work","plan","focus","signals","audit","dependency",{"skillNo":246,"name":247,"nameZh":17,"description":248,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":249,"categories":250,"keywords":251,"publishedAt":52},"01M70KPYH9QNHCNME5GJQGE22K","readonly-sql-guard","Make an agent's database access provably read-only. Use when an agent runs caller-supplied SQL against a production\u002FERP\u002Fanalytics database (a \"query\" MCP tool, text-to-SQL, an admin console), or when reviewing DB-access code for write\u002FDDL\u002Fside-effect\u002Ftransaction-escape risks. Checks what a statement CALLS, not just its shape.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fdatabase\u002Freadonly-sql-guard\u002FSKILL.md",[],[252,253,254,255,256,257,258,36,259,260,261,262,263,264,265,33,266,267,34,268],"readonly","guard","sql guard","sql","readonly sql guard","erp","effect","read-only","db","just","tool","calls","only","MCP","access","database","query",{"skillNo":270,"name":271,"nameZh":272,"description":273,"descriptionZh":274,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":275,"licenseFileUrl":276,"sourceHtmlUrl":277,"categories":278,"keywords":285,"publishedAt":52},"01M6AFY6F7CC2BBZP1QD6VTNVC","web-artifacts-builder","Claude 网页 Artifact 构建","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","用于创建精细的、多组件的 claude.ai HTML artifact 的工具套件，采用现代前端 Web 技术（React、Tailwind CSS、shadcn\u002Fui）。适用于需要状态管理、路由或 shadcn\u002Fui 组件的复杂 artifact —— 不适用于简单的单文件 HTML\u002FJSX artifact。","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FSKILL.md",[279,282],{"categoryNo":280,"categoryName":281,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师",{"categoryNo":283,"categoryName":284,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BRASNPVNJVQQJ4KZX8XM5D","前端开发与界面实现",[286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,51,302,303,304,305,306,36,307],"artifacts builder","web","web artifacts builder","artifacts","builder","state","routing","state management","component","css","frontend","ui","Tools","file","components","shadcn","Tailwind","suite","jsx","html","single-file","ui components",{"skillNo":309,"name":310,"nameZh":311,"description":312,"descriptionZh":313,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":275,"licenseFileUrl":314,"sourceHtmlUrl":315,"categories":316,"keywords":323,"publishedAt":52},"01M6AFWF33SFV9Z3SF4PEEE4BF","webapp-testing","Playwright Web 应用测试","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","使用 Playwright 与本地 Web 应用进行交互和测试的工具包。支持验证前端功能、调试 UI 行为、捕获浏览器截图以及查看浏览器日志。","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FSKILL.md",[317,320],{"categoryNo":318,"categoryName":319,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQGD5WG86P4AQ5GPSSKBFR","测试工程师",{"categoryNo":321,"categoryName":322,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQJH394GT47X57A9Q8G7HX","测试与质量保障",[324,325,326,327,328,287,329,296,297,330,331,332,333,36,334,210,335],"webapp testing","testing","webapp","browser","playwright","applications","debugging","toolkit","logs","screenshots","local","behavior",{"skillNo":337,"name":338,"nameZh":339,"description":340,"descriptionZh":341,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":275,"licenseFileUrl":342,"sourceHtmlUrl":343,"categories":344,"keywords":351,"publishedAt":52},"01M6AF67Q67JJJ5V51JR2P52KA","discernment-nudge","回复事实核查追问","After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format.","在你给出用户可能据以行动的实质性答案或草稿之后——建议或推荐、起草的工件（如目标、计划、推介、提案或电子邮件）、估计或预测、数据分析或解读、他们可能依赖的事实声明，或多步骤论证——在最终确定回复之前调用本技能，然后，如适用，附加 2-3 个简短的后续问题，每个问题都与你刚刚产出的具体内容相关，帮助用户核查关键事实、探究推理或假设，并注意到缺失的上下文。每次对话最多执行一次。当用户询问琐碎的操作方法或简单查找、想要纯教育性解释、仅要求根据提供的内容格式化\u002F转换\u002F组装文件、正在编写将要运行的代码、正在进行创意写作或休闲聊天，或已经要求你复核、引用或审查时跳过——技能文件解释了这些边界和确切的输出格式。","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fdiscernment-nudge\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fdiscernment-nudge\u002FSKILL.md",[345,348],{"categoryNo":346,"categoryName":347,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQ6TMSBZZX4V1THHNVC815","回答复核",{"categoryNo":349,"categoryName":350,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BS5011KJDVSRXG1DC4P666","普通用户",[352,353,354,355,356,357,46,358,289,359,299,237,360,361,362,363,364,264,365,34,366,367,368,369,370,216,371],"discernment nudge","nudge","interpretation","help","run","reasoning","writing","lookup","content","review","conversation","short","up","invoke","you","analysis","claims","argument","assemble","recommendations"]