tinystruct-patterns
Ce qu’il fait
Ce guide vous explique comment utiliser le framework Java tinystruct pour créer des applications. Il permet à vos applications de fonctionner à la fois dans le terminal (ligne de commande) et sur le web, sans configuration supplémentaire.
Quand l’utiliser
- ✓Quand vous démarrez un nouveau projet avec tinystruct.
- ✓Quand vous voulez que votre application fonctionne en ligne de commande et sur le web.
- ✓Quand vous générez les scripts de démarrage (bin/dispatcher) de votre projet.
Lien du skill
https://github.com/affaan-m/ECC/blob/main/skills/tinystruct-patterns/SKILL.mdCopiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.
Comment l’utiliser
Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.
Message prêt à coller
Pour Claude Code, Codex ou Cursor : lancez-la dans le dossier du projet et le skill est installé.
Téléchargez le SKILL.md et placez-le dans le dossier de skills de votre agent.
Exemple de demande à votre IA
“Comment créer un script de démarrage pour mon projet tinystruct ?”
5 nouveaux skills par semaine. 1 minute de lecture.
Comment ça marche
Tinystruct utilise un script appelé `bin/dispatcher` (ou `bin/dispatcher.cmd` sous Windows) comme outil principal. Il permet à vos fonctions de s'exécuter à la fois dans un terminal et dans un serveur web, de manière intégrée.
Contenu technique (SKILL.md original)
Texte original de l’auteur, en anglais, directement depuis GitHub.
tinystruct Development Patterns
Architecture and implementation patterns for building modules with the tinystruct Java framework – a lightweight, high-performance framework that treats CLI and HTTP as equal citizens, requiring no main() method and minimal configuration.
Core Principle
CLI and HTTP are equal citizens. Every method annotated with @Action should ideally be runnable from both a terminal and a web browser without modification. This "dual-mode" capability is the core design philosophy of tinystruct.
Primary Development Tool: bin/dispatcher
bin/dispatcher is the default, highest-priority tool for developing, running, testing, and debugging a tinystruct application — reach for it before an IDE run configuration, a hand-written main(), curl, or a browser. Because every @Action is dual-mode by design, bin/dispatcher lets you exercise routing, argument binding, and business logic directly from the terminal, with the fastest possible feedback loop and no server/browser required.
# Run any @Action directly - the fastest way to verify a new action works
# (the class must be imported; see --import or default.import.applications in application.properties)
bin/dispatcher greet/James --import com.example.MyService
bin/dispatcher echo --words "Praise the Lord"
# Start the HTTP server when you need the web-facing counterpart
bin/dispatcher start --import org.tinystruct.system.HttpServer
# Import additional Application/MCP classes for the current run
# (one --import per class; a comma-separated list fails with ClassNotFoundException)
bin/dispatcher start --import org.tinystruct.system.HttpServer --import com.example.MyService
# Discover what's available
bin/dispatcher --help
bin/dispatcher --version
Default to this workflow: implement the @Action, run it immediately via bin/dispatcher <action> to confirm it behaves correctly in CLI mode, and only start the HTTP server (also via bin/dispatcher start ...) once you need to verify the web-facing path (e.g. mode = Mode.HTTP_POST, sessions, file uploads). Never hardcode a main(String[] args) as an app's entry point — bin/dispatcher (or bin/dispatcher.cmd on Windows) is the one entry point for every module.
Generating bin/dispatcher and bin/dispatcher.cmd
Every tinystruct project needs its launcher in bin/. The framework generates it — never write it by hand, and never copy it from another project or substitute a main(). ApplicationManager.init() writes the launcher for the current operating system into bin/ under the working directory whenever it is missing, from templates inside the tinystruct jar, with that jar's version filled in. Line endings and the executable bit are already right.
1. Find the tinystruct version the project builds against: the <tinystruct.version> property or the org.tinystruct:tinystruct dependency in pom.xml. The jar must be reachable, in ~/.m2/repository/org/tinystruct/tinystruct/<version>/ (run mvn dependency:resolve if it is not) or in the project's lib/.
2. From the project root, run the framework once:
java -cp ~/.m2/repository/org/tinystruct/tinystruct/<version>/tinystruct-<version>.jar \
org.tinystruct.system.Dispatcher --version
Replace <version> with the version found in step 1. On Windows use %USERPROFILE%\.m2\repository\org\tinystruct\tinystruct\<version>\tinystruct-<version>.jar and the same class. This creates only the script for the OS you ran it on, and only if it is not already there:
| Run on | Creates |
|---|---|
| Linux, macOS | bin/dispatcher (executable, LF) |
| Windows | bin\dispatcher.cmd (CRLF) |
3. Verify. From the project root run bin/dispatcher --version (Windows: bin\dispatcher.cmd --version). It prints Dispatcher (cli) (built on tinystruct-<version>), and the VERSION inside the script equals the jar's version. Then bin/dispatcher --help lists the commands and every imported action. Show the user the file you created.
4. Get both scripts by running step 2 on each OS, or let a teammate or CI on the other OS run it and commit the result. Commit both, so a checkout on either OS works. Do not try to fake the other OS with -Dos.name=…: on Windows it fails (UnsupportedOperationException from setPosixFilePermissions) and leaves an empty bin/dispatcher. Recommended .gitattributes, so a checkout does not corrupt the line endings:
…
Questions fréquentes
Qu'est-ce que `bin/dispatcher` ?
C'est un script qui démarre votre application tinystruct. C'est la méthode recommandée pour lancer, tester et déboguer votre code, qu'il s'agisse de la ligne de commande ou du web.
Pourquoi utiliser `bin/dispatcher` plutôt qu'une méthode `main()` ?
Le `bin/dispatcher` est conçu pour tinystruct et permet à vos fonctions de fonctionner dans les deux modes (terminal et web) sans modification. Cela simplifie le développement et la configuration.
Comment `bin/dispatcher` est-il créé ?
Le framework tinystruct le génère automatiquement s'il n'existe pas. Il suffit d'exécuter une fois une commande Java précise, et il crée le script adapté à votre système d'exploitation.
Détails
Description originale de l’auteur
Expert guidance for developing with the tinystruct Java framework. Use when working on the tinystruct codebase or any project built on tinystruct — including generating the bin/dispatcher and bin/dispatcher.cmd launcher scripts when a project lacks them, creating Application classes, @Action-mapped routes, unit tests, ActionRegistry, HTTP/CLI dual-mode handling, the built-in HTTP server, the event
repo: affaan-m/ECC
Popularité
- Étoiles GitHub
- 280k
- Position au classement
- #424
- Licence
- MIT
- Mis à jour
- 15/10/2026
Commentaires
- …
Autres skills de ce dépôt
accessibility
280kAide votre agent à créer des interfaces accessibles à tous. Vérifie que sites et applis fonctionnent bien pour les personnes handicapées, aveugles ou à mobilité réduite.
agent-architecture-audit
280kPermet à votre agent de vérifier que tout fonctionne correctement. Il repère et corrige les problèmes des systèmes d'IA pour qu'ils se comportent comme prévu.
agent-eval
280kAide votre agent à comparer différents outils de codage IA. Il mesure lequel est le plus rapide, le moins cher et le plus fiable pour des tâches précises.
agent-harness-construction
280kRend votre agent plus efficace dans l'exécution des tâches. Il optimise les outils et les instructions qu'il utilise pour augmenter ses chances de réussite.
Skills similaires
shopify
260kPermet à votre agent de lire et mettre à jour les données de votre boutique Shopify (produits, stocks, commandes, clients) via l'API GraphQL.
rest-graphql-debug
260kAide votre agent à trouver pourquoi un appel d'API REST ou GraphQL échoue, en vérifiant chaque couche : connexion, authentification, requête, réponse.
har-derived-api-client
260kAide votre agent à enregistrer une fois le trafic réseau d'un site web, puis à construire un client API direct, pour ne plus cliquer sur la page à chaque fois.