skills/dnd-kit-implementation/SKILL.md
Guide for implementing sortable and droppable components using dnd-kit library. Use this skill when building React applications that require drag-and-drop functionality with both container reordering (useSortable) and item dropping (useDroppable) capabilities, such as Kanban boards, file management systems, or playlist editors.
npx skillsauth add atman-33/atman-workspace dnd-kit-implementationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides patterns for implementing drag-and-drop functionality using dnd-kit library that supports both sortable containers and droppable targets simultaneously.
The key to combining useSortable and useDroppable is conditional logic based on drag context:
This is achieved by detecting what's currently being dragged and enabling only the appropriate functionality.
const SortableDroppableContainer = ({ container }) => {
// useSortable for container reordering
const {
attributes,
listeners,
setNodeRef: setSortableRef,
transform,
transition,
isDragging,
} = useSortable({ id: container.id });
// useDroppable for receiving items
const { setNodeRef: setDroppableRef, isOver } = useDroppable({
id: container.id,
});
// Active element from context
const { active } = useDndContext();
// Determine behavior based on what's being dragged
const isItem = active?.id?.toString().startsWith('item-');
const isContainer = active?.id?.toString().startsWith('container-');
// Apply conditional refs
const setNodeRef = isItem ? setDroppableRef : setSortableRef;
return (
<div ref={setNodeRef} {...(isContainer ? attributes : {})} style={style}>
<div {...(isContainer ? listeners : {})}>{/* Drag handle */}</div>
{/* Container content */}
</div>
);
};
useSortable and useDroppable in the same componentuseDndContext() to check what's being draggedcontainer-* and item-* to distinguish types// Containers
const containerId = `container-${id}`;
// Items
const itemId = `item-${id}`;
This convention makes conditional logic clean and maintainable.
When updating container items, always create new objects:
// ❌ Won't trigger re-render
containers.items.push(newItem);
// ✅ Correct - creates new reference
setContainers(prev => prev.map(c =>
c.id === targetId
? { ...c, items: [...c.items, newItem] }
: c
));
For detailed implementation examples and code patterns, see:
tools
Zenn記事のMarkdown校正を行うスキル。記事を読み、Zenn独自記法の正確性・見出し構造・コードブロック・リンク・画像・テーブル・埋め込み・メッセージ/アコーディオン記法をチェックし、改善提案を行う。ユーザーが「Zenn記事を校正して」「Zennの記法をチェックして」「記事をレビューして」「Markdown確認して」と依頼した際に使用する。
tools
Develop React applications for VS Code Webview surfaces. Use when working on the `webview-ui` package, creating features, components, or hooks for VS Code extensions. Includes project structure, coding guidelines, and testing instructions.
testing
Best practices for reliable terminal command execution and output capture. Use this skill when running shell commands, especially in environments like WSL where output might be truncated or lost, to ensure results are properly captured and inspected.
databases
Supabaseデータベースマイグレーションの準備を行うスキル。バックアップの作成と差分マイグレーションファイルの生成を実施します。ユーザーが「マイグレーションを準備」「バックアップと差分を作成」「マイグレーションファイルを生成」などのリクエストをした際に使用します。