add-puzzle-type
Über
Diese Claude Skill strukturiert einen neuen Puzzle-Typ über alle 10+ Integrationspunkte im jigsawR-Paket hinweg. Sie automatisiert die Erstellung des Kernmoduls, die Pipeline-Verknüpfung, ggplot-Layer, Konfigurationsaktualisierungen und einen Testrahmen. Nutzen Sie sie, wenn Sie einen völlig neuen Puzzle-Typ hinzufügen, um eine vollständige, durchgängige Integration sicherzustellen.
Schnellinstallation
Claude Code
Empfohlennpx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/add-puzzle-typeKopieren Sie diesen Befehl und fügen Sie ihn in Claude Code ein, um diese Fähigkeit zu installieren
Dokumentation
Add Puzzle Type
Scaffold a new puzzle type across all pipeline integration points in jigsawR.
When to Use
- Adding a completely new puzzle type to the package
- Following the established integration checklist (CLAUDE.md 10-point pipeline)
- Ensuring nothing is missed when wiring a new type end-to-end
Inputs
- Required: New type name (lowercase, e.g.
"triangular") - Required: Geometry description (how pieces are shaped/arranged)
- Required: Whether the type needs external packages (add to Suggests)
- Optional: Parameter list beyond the standard (grid, size, seed, tabsize, offset)
- Optional: Reference implementation or algorithm source
Procedure
Step 1: Create Core Puzzle Module
Create R/<type>_puzzle.R with the internal generation function:
#' Generate <type> puzzle pieces (internal)
#' @noRd
generate_<type>_pieces_internal <- function(params, seed) {
# 1. Initialize RNG state
# 2. Generate piece geometries
# 3. Build edge paths (SVG path data)
# 4. Compute adjacency
# 5. Return list: pieces, edges, adjacency, metadata
}
Follow the pattern in R/voronoi_puzzle.R or R/snic_puzzle.R for structure.
Got: Function returns a list with $pieces, $edges, $adjacency, $metadata.
If fail: Compare the return structure against generate_voronoi_pieces_internal() to identify missing list elements or incorrect types.
Step 2: Wire into jigsawR_clean.R
Edit R/jigsawR_clean.R:
- Add
"<type>"to thevalid_typesvector - Add type-specific parameter extraction in the params section
- Add validation logic for type-specific constraints
- Add filename prefix mapping (e.g.,
"<type>"->"<type>_")
# In valid_types
valid_types <- c("rectangular", "hexagonal", "concentric", "voronoi", "snic", "<type>")
Got: generate_puzzle(type = "<type>") is accepted without "unknown type" error.
If fail: Verify the type string is added to valid_types exactly as spelled, and that parameter extraction covers all required type-specific arguments.
Step 3: Wire into unified_piece_generation.R
Edit R/unified_piece_generation.R:
- Add dispatch case in
generate_pieces_internal() - Add fusion handling if the type supports PILES notation
# In the switch/dispatch
"<type>" = generate_<type>_pieces_internal(params, seed)
Got: Pieces are generated when the type is dispatched.
If fail: Confirm the dispatch case string matches the type name exactly and that generate_<type>_pieces_internal is defined and exported from the puzzle module.
Step 4: Wire into piece_positioning.R
Edit R/piece_positioning.R:
Add positioning dispatch for the new type. Most types use shared positioning logic, but some need custom handling.
Got: apply_piece_positioning() handles the new type without errors and pieces are placed at correct coordinates.
If fail: Check whether the new type needs custom positioning logic or can reuse the shared positioning path. Add a dispatch case if the default path does not apply.
Step 5: Wire into unified_renderer.R
Edit R/unified_renderer.R:
- Add rendering case in
render_puzzle_svg() - Add edge path function:
get_<type>_edge_paths() - Add piece name function:
get_<type>_piece_name()
Got: SVG output is generated for the new type with correct piece outlines and edge paths.
If fail: Verify get_<type>_edge_paths() returns valid SVG path data and get_<type>_piece_name() produces unique identifiers for each piece.
Step 6: Wire into adjacency_api.R
Edit R/adjacency_api.R:
Add neighbor dispatch so get_neighbors() and get_adjacency() work for the new type.
Got: get_neighbors(result, piece_id) returns correct neighbors for any piece in the puzzle.
If fail: Check that the adjacency dispatch returns the correct data structure. Test with a small grid and manually verify neighbor relationships against the geometry.
Step 7: Add ggpuzzle Geom Layer
Edit R/geom_puzzle.R:
Create geom_puzzle_<type>() using the make_puzzle_layer() factory:
#' @export
geom_puzzle_<type> <- function(mapping = NULL, data = NULL, ...) {
make_puzzle_layer(type = "<type>", mapping = mapping, data = data, ...)
}
Got: ggplot() + geom_puzzle_<type>(aes(...)) renders without error.
If fail: Verify make_puzzle_layer() receives the correct type string and that the geom function is exported in the NAMESPACE via @export.
Step 8: Add Stat Dispatch
Edit R/stat_puzzle.R:
- Add type-specific default parameters
- Add dispatch case in
compute_panel()
Got: The stat layer computes puzzle geometry correctly and produces the expected number of polygons.
If fail: Check that the compute_panel() dispatch case returns a data frame with the required columns (x, y, group, piece_id) and that default parameters are sensible for the new type.
Step 9: Update DESCRIPTION
Edit DESCRIPTION:
- Add new type to the Description field text
- Add any new packages to
Suggests:(if external dependency) - Update
Collate:to include the new R file (alphabetical order)
Got: devtools::document() succeeds. No NOTE about unlisted files.
If fail: Check that the new R file is listed in the Collate: field in alphabetical order and that any new Suggests packages are spelled correctly with version constraints.
Step 10: Update config.yml
Edit inst/config.yml:
Add defaults and constraints for the new type:
<type>:
grid:
default: [3, 3]
min: [2, 2]
max: [20, 20]
size:
default: [300, 300]
min: [100, 100]
max: [2000, 2000]
tabsize:
default: 20
min: 5
max: 50
# Add type-specific params here
Got: Config is valid YAML. Defaults produce a working puzzle when used by generate_puzzle().
If fail: Validate YAML with yaml::yaml.load_file("inst/config.yml"). Ensure default grid and size values produce a sensible puzzle (not too small or too large).
Step 11: Extend Shiny App
Edit inst/shiny-app/app.R:
- Add the new type to the UI type selector
- Add conditional UI panels for type-specific parameters
- Add server-side generation logic
Got: Shiny app shows the new type in the dropdown and generates puzzles when selected.
If fail: Check that the type is added to the choices argument of the UI selector, that the conditional panel for type-specific parameters uses conditionalPanel(condition = "input.type == '<type>'"), and that the server-side handler passes the correct parameters.
Step 12: Create Test Suite
Create tests/testthat/test-<type>-puzzles.R:
test_that("<type> puzzle generates correct piece count", { ... })
test_that("<type> puzzle respects seed reproducibility", { ... })
test_that("<type> adjacency returns valid neighbors", { ... })
test_that("<type> fusion merges pieces correctly", { ... })
test_that("<type> geom layer renders without error", { ... })
test_that("<type> SVG output is well-formed", { ... })
test_that("<type> config constraints are enforced", { ... })
If the type requires an external package, wrap tests with skip_if_not_installed().
Got: All tests pass. No skips unless external dependency is missing.
If fail: Check each integration point individually. The most common issue is missing dispatch cases — run grep -rn "switch\|valid_types" R/ to find all dispatch locations.
Validation
-
generate_puzzle(type = "<type>")produces valid output - All 10 integration points are wired correctly
-
devtools::test()passes with new tests -
devtools::check()returns 0 errors, 0 warnings - Shiny app renders the new type
- Config constraints are enforced (min/max validation)
- Adjacency and fusion work correctly
- ggpuzzle geom layer renders without error
-
devtools::document()succeeds (NAMESPACE updated)
Pitfalls
- Missing dispatch case: Forgetting one of the 10+ files causes silent failure or "unknown type" errors
- strsplit with negative numbers: When creating adjacency keys with
paste(a, b, sep = "-"), negative piece labels produce keys like"1--1". Use"|"separator instead and split with"\\|". - Using
cat()for output: Always useclipackage logging wrappers (log_info,log_warn, etc.) - Collate order: DESCRIPTION Collate field must be alphabetical or dependency-ordered
- Config.yml format: Ensure YAML is valid; test with
yaml::yaml.load_file("inst/config.yml")
Related Skills
generate-puzzle— test the new type after scaffoldingrun-puzzle-tests— run the full test suite to verify integrationvalidate-piles-notation— test fusion with the new typewrite-testthat-tests— general test-writing patternswrite-roxygen-docs— document the new geom function
GitHub Repository
Verwandte Skills
content-collections
MetaDiese Skill bietet eine produktionsgetestete Einrichtung für Content Collections – ein TypeScript-first-Tool, das Markdown/MDX-Dateien in typsichere Datensammlungen mit Zod-Validierung umwandelt. Verwenden Sie ihn beim Erstellen von Blogs, Dokumentationsseiten oder inhaltsstarken Vite + React-Anwendungen, um Typsicherheit und automatische Inhaltsvalidierung zu gewährleisten. Er behandelt alles von der Vite-Plugin-Konfiguration und MDX-Kompilierung bis hin zur Deployment-Optimierung und Schema-Validierung.
polymarket
MetaDiese Fähigkeit ermöglicht es Entwicklern, Anwendungen mit der Polymarket-Prognosemärkte-Plattform zu erstellen, einschließlich API-Integration für Handel und Marktdaten. Sie bietet außerdem Echtzeit-Datenstreaming über WebSocket, um Live-Trades und Marktaktivitäten zu überwachen. Nutzen Sie sie zur Implementierung von Handelsstrategien oder zur Erstellung von Tools, die Live-Marktaktualisierungen verarbeiten.
creating-opencode-plugins
MetaDiese Fähigkeit unterstützt Entwickler dabei, OpenCode-Plugins zu erstellen, die in über 25 Ereignistypen wie Befehle, Dateien und LSP-Operationen eingreifen. Sie bietet die Plugin-Struktur, Event-API-Spezifikationen und Implementierungsmuster für JavaScript/TypeScript-Module. Nutzen Sie sie, wenn Sie den Lebenszyklus des OpenCode KI-Assistenten mit benutzerdefinierter ereignisgesteuerter Logik abfangen, überwachen oder erweitern müssen.
sglang
MetaSGLang ist ein hochperformantes LLM-Serving-Framework, das sich auf schnelle, strukturierte Generierung für JSON, Regex und agentenbasierte Workflows unter Verwendung seines RadixAttention-Prefix-Cachings spezialisiert. Es bietet deutlich schnellere Inferenz, insbesondere für Aufgaben mit wiederholten Präfixen, was es ideal für komplexe, strukturierte Ausgaben und Mehrfachdialoge macht. Wählen Sie SGLang gegenüber Alternativen wie vLLM, wenn Sie constrained decoding benötigen oder Anwendungen mit umfangreicher Präfix-Weitergabe entwickeln.
