Skip to content

feat: add tinystruct-patterns skill and bootstrapping guidance#1336

Open
m0ver wants to merge 7 commits intoaffaan-m:mainfrom
m0ver:feat/tinystruct-patterns-skill
Open

feat: add tinystruct-patterns skill and bootstrapping guidance#1336
m0ver wants to merge 7 commits intoaffaan-m:mainfrom
m0ver:feat/tinystruct-patterns-skill

Conversation

@m0ver
Copy link
Copy Markdown

@m0ver m0ver commented Apr 9, 2026

What Changed

Introduced a new skill module: skills/tinystruct-patterns/. This provides production-grade, pattern-based guidance for the tinystruct Java framework, following the repository's convention for framework-specific patterns.

New files added:

skills/tinystruct-patterns/
├── SKILL.md                 ← Core patterns & auto-activation logic
└── references/
    ├── architecture.md      ← Key abstractions (Application, Context)
    ├── routing.md           ← Regex-based @Action routing & HTTP modes
    ├── data-handling.md     ← Framework-native JSON via Builder
    ├── system-usage.md      ← CLI vs HTTP context & event bus
    └── testing.md           ← Integration testing with ActionRegistry

Key Patterns & Breakthroughs:

  • Automated CLI Bootstrapping: Documents how to generate the bin/dispatcher entry point via ApplicationManager.init(), solving the primary "first-run" friction point for new users.
  • Dual-Mode Dispatching: Explicitly handles the "CLI and HTTP are equal citizens" principle, ensuring @Action methods are built to run in both environments seamlessly.
  • Dependency-Free JSON: Enforces use of the internal Builder component, preventing runtime issues common when developers attempt to use external JSON libraries like Jackson.

Why This Change

This change adds a critical piece of domain knowledge for Java developers using lightweight alternatives to Spring. The tinystruct framework treats terminal commands and web requests as identical primitives, a model that requires specific AI guidance to:

  1. Avoid Redundant Logic: Preventing developers from writing separate CLI and Web pathways.
  2. Handle Context Properly: Ensuring CLI arguments and HTTP attributes are accessed via the unified Context object.
  3. Streamline Setup: By exposing the ApplicationManager generation utility, we automate the creation of the project's execution environment.

This new module provides the high-level architectural constraints and "Red Flags" necessary for Claude to act as an expert pair programmer in this ecosystem.

Testing Done

  • Source Verification: Verified ApplicationManager generation logic against the latest tinystruct source.
  • Annotation Analysis: Confirmed @Action registration and Regex group mapping logic.
  • Pathing Tests: Validated that bin/dispatcher vs bin/dispatcher.cmd logic matches the framework's platform-aware implementation.
  • Manual Review: Checked SKILL.md against ECC's 800-line recommended maximum (this module is ~200 lines).

Type of Change

  • fix: Bug fix
  • feat: New feature entry
  • refactor: Code refactoring
  • docs: Documentation expansion
  • test: Tests addition

Security & Quality Checklist

  • Credential-Free: No secrets, PI, or environment-specific paths committed.
  • Conventional Commits: Commit message feat: add tinystruct-patterns skill follows repo standard.
  • Framework Native: Promotes Builder for JSON to avoid third-party dependency creep.
  • Auto-Activation: "When to Activate" section tuned for effective context-triggered loading.

Documentation

  • Updated relevant documentation (Internal references folder)
  • Added comments for complex logic
  • README updated (via self-documenting skill discovery)

Summary by cubic

Adds a new skills/tinystruct-patterns/ module with production-ready patterns for the tinystruct Java framework, covering CLI bootstrapping, dual CLI/HTTP routing, native JSON, and testing. The routing guide adds parameter-to-regex mapping, Request/Response injection, and a clear HTTP mode matrix; the testing guide now shows Settings init, app.init()/app.invoke(), and registry path matching.

  • New Features

    • Added skills/tinystruct-patterns/ with SKILL.md and reference guides.
    • Bootstrapping via ApplicationManager.init() to generate bin/dispatcher (Windows/macOS/Linux).
    • Expanded @Action routing (parameter → regex, dependency injection, mode coverage).
    • Standardized JSON via org.tinystruct.data.component.Builder; JUnit 5 guide expanded with proper setup and ActionRegistry matching.
    • Added “Red Flags & Anti-patterns” and a technical reference map.
  • Refactors

    • Reorganized docs into “When to Use”, “How It Works”, and “Examples”.
    • Simplified examples to return Builder directly; clarified event bus, context handling, and regex-based routing.

Written for commit 722c052. Summary will update on new commits.

Summary by CodeRabbit

  • Documentation
    • Added comprehensive developer guidance covering architecture, bootstrapping, routing, request/response modes, and JSON data handling via the lightweight Builder.
    • Documented system usage for CLI and HTTP modes, session and event-driven patterns, and runtime configuration.
    • Added testing guidance with JUnit 5 best practices and a table of recommended patterns and anti-patterns for building modules and actions.

@ecc-tools
Copy link
Copy Markdown
Contributor

ecc-tools bot commented Apr 9, 2026

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

📝 Walkthrough

Walkthrough

Adds documentation under skills/tinystruct-patterns/ including a patterns guide and reference pages covering architecture, routing (@Action), data handling (Builder), system usage (Context/sessions/events), and JUnit5 testing. No code or public API changes.

Changes

Cohort / File(s) Summary
Patterns Guide & References
skills/tinystruct-patterns/SKILL.md, skills/tinystruct-patterns/references/architecture.md, skills/tinystruct-patterns/references/data-handling.md, skills/tinystruct-patterns/references/routing.md, skills/tinystruct-patterns/references/system-usage.md, skills/tinystruct-patterns/references/testing.md
Added six documentation pages describing framework architecture, @Action routing and Mode semantics, parameter-to-regex mapping, Builder JSON usage and parsing, Context/session/event usage, template behavior, CLI/HTTP bootstrap, and JUnit5 testing patterns. Documentation-only; no code/API changes. Review focus: examples, routing descriptions, and accuracy of references.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐇 I hopped through pages, tidy and bright,
Actions and builders lined up just right.
Context and sessions, routes in a row,
Tests to confirm the tinystruct flow.
A small patch of docs — let knowledge grow. 🌱

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the main change: adding a new tinystruct-patterns skill module with bootstrapping guidance documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (1)
skills/tinystruct-patterns/references/system-usage.md (1)

20-31: Mark authentication/session values as illustrative-only.

Line 22 hardcodes "42" as userId; add a short note that this is demo code and must be replaced by authenticated identity resolution in real usage to avoid insecure copy/paste.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/tinystruct-patterns/references/system-usage.md` around lines 20 - 31,
The login/profile example hardcodes a demo session value ("42") in the
login(Request) method and reads it in profile(Request) via
request.getSession().setAttribute/getAttribute; update the comments to mark the
hardcoded userId as illustrative-only and add a short note in or above the
login(Request) method (and optionally above profile(Request)) stating this must
be replaced with real authenticated identity resolution (e.g., verified user id
from authentication token or user service) in production to prevent insecure
copy/paste.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@skills/tinystruct-patterns/references/architecture.md`:
- Around line 1-82: Add three top-level sections "When to Use", "How It Works",
and "Examples" to this reference and reorganize content under them: put a short
decision guide (when to pick tinystruct, target use-cases) under "When to Use";
move the Core Architecture, Key Abstractions (mentioning AbstractApplication,
`@Action`, ActionRegistry, Action, Context, Dispatcher, HttpServer) and Package
Map into "How It Works" with a brief explanation of dispatch flow and template
behavior (include templateRequired and getContext()/setVariable usage); and
create "Examples" that show minimal usage scenarios referencing
AbstractApplication.init(), setTemplateRequired(false), using `@Action-annotated`
methods and dispatcher invocation (bin/dispatcher) as concrete examples. Ensure
headings are Markdown-level (e.g., ## When to Use) and keep each section
concise.

In `@skills/tinystruct-patterns/references/data-handling.md`:
- Around line 1-34: Add the required skill-structure headings to this doc:
insert "When to Use", "How It Works", and "Examples" sections; move the existing
"Serialization" and "Parsing" content under "Examples" and keep the code
snippets as-is, add a short "When to Use" paragraph explaining scenarios to
prefer org.tinystruct.data.component.Builder (e.g., lightweight, zero external
deps) and a concise "How It Works" paragraph describing the Builder behavior and
integration with AbstractApplication result handling; ensure you mention Builder
and AbstractApplication by name so the guidance is explicit.

In `@skills/tinystruct-patterns/references/routing.md`:
- Around line 1-57: Normalize this reference by restructuring it into the
required skill-doc format: add a "When to Use" section explaining scenarios to
use the `@Action` annotation (e.g., routing CLI/HTTP commands, parameterized
paths), a "How It Works" section that summarizes Mode values, path parameter
type-to-regex mapping, automatic injection via ActionRegistry/Context (mention
Request and Response injection), and the regex generation behavior shown by
getUser and search; and add an "Examples" section that preserves the existing
code samples (the `@Action` declaration, getUser, search, and upload examples)
with brief captions. Ensure headings are exactly "When to Use", "How It Works",
and "Examples" and keep all referenced symbols (`@Action`, Mode, Request,
Response, ActionRegistry, Context, getUser, search, upload) so the content
remains identical but reorganized.

In `@skills/tinystruct-patterns/references/system-usage.md`:
- Around line 1-72: Add three required top-level sections "When to Use", "How It
Works", and "Examples" to this skill markdown and reorganize the existing
content into them: put a short guidance sentence about appropriate scenarios
(e.g., CLI vs HTTP modes, session use) under "When to Use"; move the explanation
of mechanics (Context CLI flags, session management examples using `@Action`
methods like echo(), login(), profile(), and the Event system with
OrderCreatedEvent and EventDispatcher usage) into "How It Works"; and
consolidate runnable snippets and commands (CLI usages, HTTP server start,
generate/sql examples, and the code examples shown) under "Examples". Preserve
all current text and code blocks (including symbols like `@Action`, getContext(),
Request.getSession(), OrderCreatedEvent, EventDispatcher.getInstance()) but
re-label and reorder them into these three headings to meet the required skill
format.

In `@skills/tinystruct-patterns/references/testing.md`:
- Around line 1-55: Add the required top-level sections "When to Use", "How It
Works", and "Examples" to the existing markdown: move the guidance about JUnit 5
and singleton ActionRegistry into "When to Use" as usage guidance, explain the
testing approach and test setup (Settings, setUp(), why fresh ActionRegistry
state) under "How It Works", and place the current code blocks and the "Testing
via ActionRegistry" snippet under "Examples" (keep the reference to
ActionRegistryTest). Ensure headings are exact: "When to Use", "How It Works",
and "Examples" and preserve the existing code samples and explanatory text
beneath the appropriate headings.

In `@skills/tinystruct-patterns/SKILL.md`:
- Around line 11-196: Rename the top-level heading "## When to Activate" to "##
When to Use" and insert two new top-level sections "## How It Works" and "##
Examples"; move or duplicate relevant explanatory content into "How It Works"
(describe framework behavior: Application extending AbstractApplication,
Context, `@Action` routing, Builder JSON handling, dispatcher generation via
ApplicationManager.init()) and create a concise "Examples" section that reuses
the existing code snippets (MyService, getUser, login, getData) as illustrative
examples. Ensure headings are exactly "## When to Use", "## How It Works", and
"## Examples" so the file conforms to the skills/*.md contract and retain
existing guidance about configuration, testing, and anti-patterns under
appropriate sections.

---

Nitpick comments:
In `@skills/tinystruct-patterns/references/system-usage.md`:
- Around line 20-31: The login/profile example hardcodes a demo session value
("42") in the login(Request) method and reads it in profile(Request) via
request.getSession().setAttribute/getAttribute; update the comments to mark the
hardcoded userId as illustrative-only and add a short note in or above the
login(Request) method (and optionally above profile(Request)) stating this must
be replaced with real authenticated identity resolution (e.g., verified user id
from authentication token or user service) in production to prevent insecure
copy/paste.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aaf3dd05-cee8-496a-993d-9dfc02b3ad22

📥 Commits

Reviewing files that changed from the base of the PR and between 0513898 and d708129.

📒 Files selected for processing (6)
  • skills/tinystruct-patterns/SKILL.md
  • skills/tinystruct-patterns/references/architecture.md
  • skills/tinystruct-patterns/references/data-handling.md
  • skills/tinystruct-patterns/references/routing.md
  • skills/tinystruct-patterns/references/system-usage.md
  • skills/tinystruct-patterns/references/testing.md

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 9, 2026

Greptile Summary

This PR adds a new skills/tinystruct-patterns/ module with six files covering architecture, routing, data handling, system usage, and testing for the tinystruct Java framework. Several code example correctness issues flagged in prior review rounds remain unresolved, particularly the ActionRegistry.get() vs getAction() API name mismatch across SKILL.md and testing.md, the contradictory path-parameter syntax ({id} in routing.md vs (\\d+) in SKILL.md), and the testRouting() snippet operating on an uninitialized singleton registry. The newly found missing @Test on testHello() in testing.md means that test will silently not execute.

Confidence Score: 4/5

The skill files contain multiple still-unresolved P1 code example errors that will produce compile failures or silent test gaps for developers copying them verbatim.

Several P1 findings from prior review rounds remain (API name mismatch, routing syntax inconsistency, empty-registry test), and a new P1 was found this round (missing @Test on testHello()). Some previously flagged issues were fixed (Builder.put() chaining, setUp() brace/double-init), which is positive progress, but the open items are still blockers for accurate developer guidance.

skills/tinystruct-patterns/SKILL.md and skills/tinystruct-patterns/references/testing.md need the most attention for API consistency and compilable examples.

Important Files Changed

Filename Overview
skills/tinystruct-patterns/SKILL.md Core skill file with good structure; still has unresolved registry.get() vs registry.getAction() API name mismatch and (\\d+) vs {id} routing syntax inconsistency with routing.md flagged in prior review rounds.
skills/tinystruct-patterns/references/testing.md Contains a missing @Test on testHello() (new finding), plus previously flagged issues: misleading prose claiming setConfiguration() triggers init(), and testRouting() snippet using an uninitialized ActionRegistry singleton.
skills/tinystruct-patterns/references/routing.md Uses {id} placeholder syntax in examples, contradicting SKILL.md which shows raw (\\d+) regex — inconsistency flagged in prior review round, still unresolved.
skills/tinystruct-patterns/references/architecture.md Clean architecture overview with accurate package map and key abstraction table; no issues found.
skills/tinystruct-patterns/references/data-handling.md Correct void-style Builder.put() usage throughout; serialization and parsing examples look accurate.
skills/tinystruct-patterns/references/system-usage.md Context/CLI args, session management, and event system examples look correct and consistent; no issues found.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Incoming Request] --> B{Dispatcher}
    B -->|CLI: bin/dispatcher path/args| C[CLI Mode]
    B -->|HTTP: GET/POST/PUT/DELETE| D[HTTP Mode]
    C --> E[ActionRegistry.getAction]
    D --> E
    E --> F{Mode Filter}
    F -->|Mode.DEFAULT| G[Any trigger]
    F -->|Mode.CLI| H[CLI only]
    F -->|Mode.HTTP_GET / POST / etc.| I[HTTP method match]
    G --> J[Inject Context / Request / Response]
    H --> J
    I --> J
    J --> K[Invoke @Action method]
    K --> L{Return type}
    L -->|Builder| M[Auto-serialize to JSON]
    L -->|String / primitive| N[Write to response / stdout]
Loading

Reviews (4): Last reviewed commit: "Update skills/tinystruct-patterns/refere..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="skills/tinystruct-patterns/references/routing.md">

<violation number="1" location="skills/tinystruct-patterns/references/routing.md:16">
P2: The routing example incorrectly suggests `--id` argument metadata binds to `int id` without a route parameter, which is inconsistent with documented path-segment binding.</violation>
</file>

<file name="skills/tinystruct-patterns/references/data-handling.md">

<violation number="1" location="skills/tinystruct-patterns/references/data-handling.md:17">
P2: Serialization example contradicts the skill’s framework-native pattern by returning `response.toString()` instead of returning `Builder` directly.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

…ormat

- Reorganize SKILL.md and all reference documents into "When to Use", "How It Works", and "Examples" sections to conform to project standards.
- Refine data-handling.md example to return Builder objects directly, leveraging framework auto-serialization.
- Simplify @action examples in routing.md for better readability.
- Clarify framework mechanics including CLI bootstrapping via ApplicationManager.init(), event-driven architecture, and regex-based routing.
@ecc-tools
Copy link
Copy Markdown
Contributor

ecc-tools bot commented Apr 9, 2026

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 9, 2026

Tip:

Greploop — Automatically fix all review issues by running /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.

Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 6 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="skills/tinystruct-patterns/references/routing.md">

<violation number="1" location="skills/tinystruct-patterns/references/routing.md:34">
P2: Example mixes `Mode.HTTP_POST` with a CLI dispatcher command, contradicting mode semantics and likely misleading users.</violation>
</file>

<file name="skills/tinystruct-patterns/references/testing.md">

<violation number="1" location="skills/tinystruct-patterns/references/testing.md:50">
P2: Routing test example omits required app/bootstrap setup before querying singleton `ActionRegistry`, making the example potentially order-dependent.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@ecc-tools
Copy link
Copy Markdown
Contributor

ecc-tools bot commented Apr 10, 2026

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@ecc-tools
Copy link
Copy Markdown
Contributor

ecc-tools bot commented Apr 10, 2026

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@ecc-tools
Copy link
Copy Markdown
Contributor

ecc-tools bot commented Apr 10, 2026

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="skills/tinystruct-patterns/references/testing.md">

<violation number="1" location="skills/tinystruct-patterns/references/testing.md:28">
P2: Java test example is malformed: duplicated app initialization and missing closing brace leave `setUp()` unterminated.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@ecc-tools
Copy link
Copy Markdown
Contributor

ecc-tools bot commented Apr 10, 2026

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@ecc-tools
Copy link
Copy Markdown
Contributor

ecc-tools bot commented Apr 10, 2026

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant