Back to Skills

tinystruct-patterns

Expert guidance for developing with the tinystruct Java framework. Use when working on the tinystruct codebase or any project built on tinystruct — including creating Application classes, @Action-mapped routes, unit tests, ActionRegistry, HTTP/CLI dual-mode handling, the built-in HTTP server, the event system, JSON with Builder/Builders, database persistence with AbstractData, POJO generation, Server-Sent Events (SSE), file uploads, and outbound HTTP networking.

230,578stars35,187forksUpdated 7/17/2026

Security Assessment

High Risk(30/100)

Detected risks:

Secret Exposure([SKILL.md] password=, [references/database.md] password=)
Privilege Escalation([references/system-usage.md] runAs, [SKILL.md] runAs)
Security Score30/100

About tinystruct-patterns

This skill provides expert guidance for developing with the tinystruct Java framework, a lightweight, high-performance framework whose core philosophy is that CLI and HTTP are equal citizens. It solves the problem of building applications that must run identically from a terminal and a web browser without a main() method and with minimal configuration. Every method annotated with @Action becomes a routable endpoint for both environments, and applications are created by extending AbstractApplication, which provides lifecycle hooks like init() and access to the per-request Context.

Concretely, the skill covers routing via the ActionRegistry, which maps path segments to method arguments; HTTP mode disambiguation using @Action with mode = Mode.HTTP_POST; native zero-dependency JSON serialization with the Builder and Builders components; and database persistence using AbstractData POJOs paired with XML mapping files, including POJO generation from tables via the generate command. It documents Server-Sent Events through SSEPushManager (push and broadcast), file uploads via FileEntity and request.getAttachments(), and outbound HTTP with URLRequest and HTTPHandler. It also details native Model Context Protocol support starting with SDK version 1.7.26, showing how to build an MCPTool with @Argument-declared parameters, register tools on an MCPServer via registerTool(), and run everything through bin/dispatcher, while warning strongly about sanitizing tool inputs to prevent prompt injection.

The skill targets Java developers working on the tinystruct codebase or projects built on it, especially those creating Application modules, defining routes and CLI actions, writing unit tests, and configuring the built-in HTTP server. Configuration is managed in src/main/resources/application.properties, covering database driver and URL, server.port, default.home.page, default.language, and session settings. It is best activated when debugging routing conflicts, parsing CLI arguments, or wiring database connections and system settings.

FAQ

What makes tinystruct different from other Java frameworks?

Its core principle is that CLI and HTTP are equal citizens: every @Action-annotated method should be runnable from both a terminal and a web browser without modification, and applications need no main() method and minimal configuration.

How do I create an application and define routes?

Extend AbstractApplication, which provides lifecycle hooks like init() and access to the request Context, then annotate methods with @Action to expose them as routable endpoints. The ActionRegistry maps path segments to method arguments.

How is JSON and database persistence handled?

Use the native Builder and Builders components for zero-dependency JSON serialization. Database persistence uses AbstractData POJOs paired with XML mapping files for CRUD, and POJOs can be generated from tables with the generate command.

Does tinystruct support the Model Context Protocol?

Yes, natively starting with SDK version 1.7.26. You create tools by extending org.tinystruct.mcp.MCPTool with @Argument-declared parameters, register them on an MCPServer via registerTool(), and run via bin/dispatcher. Tool inputs must be validated and sanitized to prevent prompt injection.

Where is configuration stored?

In src/main/resources/application.properties, covering settings such as the database driver and database.url, server.port, default.home.page, default.language, and session configuration.

All Files

7 files
references/data-handling.md1.8 KB
View
references/system-usage.md2.8 KB
View
references/architecture.md3.7 KB
View
references/routing.md2.4 KB
View
SKILL.md11.6 KB
View
references/database.md2.6 KB
View
references/testing.md1.9 KB
View

Install tinystruct-patterns

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill