andrea-magni/mars/mars-new-project
Claude Code and agent skill by andrea-magni/mars
- community
Checking that the SKILL.md file is still in the repository.
Scaffold a new REST server project with MARS-Curiosity (Delphi REST library). Use this skill whenever the user wants to create, bootstrap, or set up a new MARS server, a new Delphi REST API/server/microservice/web service based on MARS, or asks "how do I start a MARS project". Also use it when the user has an OpenAPI (Swagger 3) document to implement as a MARS server, and when adding a new host flavor or deploying a MARS server (console, VCL/FMX GUI, Windows service, ISAPI on IIS, Apache module…
Install
npx vskill@latest install andrea-magni/mars/mars-new-projectSKILL.md
Create a new MARS server project
MARS-Curiosity (https://github.com/andrea-magni/MARS) is a REST library for Delphi. A MARS server has three moving parts, regardless of host type:
- A project file (.dpr) — the host: console app, VCL/FMX form, Windows service, ISAPI dll, Apache module, or Linux daemon. The host creates an HTTP server (typically
TMARShttpServerIndy) bound to the engine. - `Server.Ignition.pas` — creates the singleton
IMARSEngine(TServerEngine.Default), loads configuration, and registers applications withAddApplication(AName, ABasePath, AResourceMasks). - Resource units (`Server.Resources.*.pas`) — plain classes annotated with attributes (
[Path],[GET],[Produces], ...) and registered in theirinitializationsection viaMARSRegister(...). This JAX-RS style is the primary MARS model. As an addition (not a replacement), endpoints can also be defined as routes in code (Server.Routes*.pas,MARS.Core.Routes, Express style), next to the resources.
Endpoint URLs compose as: engine base path (/rest by default) + application base path (/default) + resource [Path] + method [Path]. So the HelloWorld template answers at http://localhost:8080/rest/default/helloworld.
Two ways to scaffold
Option A — copy the official template (recommended for full projects)
Demos/MARSTemplate/ in the MARS repository is the canonical project group: console host, VCL form host, FMX host, Windows service, ISAPI, Apache module, FCGI, Linux daemon, tests, and an FMX client — all sharing the same Server.Ignition.pas and resource units. To scaffold:
- Copy the whole
Demos/MARSTemplatefolder to the target location, outside the MARS folder (the setup's uninstaller deletes the MARS folder; MARSCmd usesDocuments\MARS Projects\<name>). The.dprojsearch paths and theRootFolderofServer.Resources.OpenAPI.pasrefer to the MARS folder as..\..\({bin}\..\..\..\): outsideDemos\rewrite them as$(MARSDIR)\(IDE environment variable set by the setup) and drop the..\..\Sourceinclause/DCCReferenceofMARS.Linux.Daemon, as MARSCmd does. - Rename files and rename the
MARSTemplateprefix inside.dpr/.dproj/.groupprojfiles to the new project name (keepServer.*.pasunit names as they are — the engine registers resources by unit name mask'Server.Resources.*'). - Delete the host flavors the user does not need.
- Rename the ini file in
bin/to match the new executable name.
Pick the template:
Demos/MARSTemplate/(default): Indy, endpoints as resource classes;Demos/MARSTemplateDCS/: the same on Delphi Cross Socket, if the user asks for the DCS transport;Demos/MARSTemplateRoutes/: the same asMARSTemplate, with its sample endpoints defined as routes in code (Server.Routes.pas,MARS.Core.Routes, Express style), only if the user asks for route-based / Express-style endpoints. Routes are in addition to resources: token (login) and OpenAPI stay resources there too, and resource units can be added to that project as to any other ('Server.Resources.*').
MARSCmd (Utils\Bin\Win32\MARScmd_VCL.exe) lists the three templates and does all the steps above. From the command line (prefer it when you can run programs: it does steps 1, 2 and 4 exactly as the tool, with a random JWT.Secret), use Utils\Bin\Win32\MARScmd.exe:
Default destination: Documents\MARS Projects\<ProjectName>; a destination inside the MARS folder needs --allow-inside; exit code 0 = created, 1 = error (i.e. destination not empty), 2 = wrong command line. Then delete the host flavors the user does not need (step 3).
Option B — generate a minimal project from bundled templates
For a lean, from-scratch server (one console host, HelloWorld + Token resources, ini config), generate the files from assets/ in this skill directory, replacing every occurrence of {{PROJECT_NAME}} with the project name (a valid Delphi identifier):
| Template | Target file | |
|---|---|---|
assets/ConsoleServer.dpr.template | {{PROJECT_NAME}}Server.dpr | |
assets/Server.Ignition.pas.template | Server.Ignition.pas | |
assets/Server.Resources.HelloWorld.pas.template | Server.Resources.HelloWorld.pas | |
assets/Server.Resources.Token.pas.template | Server.Resources.Token.pas | |
assets/ServerConfig.ini.template | bin\{{PROJECT_NAME}}Server.ini (next to the executable) |
Then create a .dproj for it (or let the user open the .dpr in the IDE and save). Set the output directory to bin\ so the executable sits next to its ini file.
Option C — from an OpenAPI document (MARSgen)
When the API is described by an OpenAPI 3.0/3.1 document (JSON or YAML, file or URL), generate the project with Utils\Bin\Win32\MARSgen.exe: it runs MARSCmd (same templates, same options) and adds the resources of every operation, the Delphi types of the schemas, and the links (Server.<Api> in the uses of Server.Ignition, the base path of the document as engine/application paths, title/version in Server.ini):
Every operation answers 501 until implemented: override its Do<Operation> method in Server.Resources.<Name>.pas (the user's unit; *.Base.pas units are generated, never edit them). Keep <Api>.marsgen.json with the sources: MARSgen update <folder> imports the document again after it changes, never touching the user's units. See the mars-development skill, references/marsgen.md.
Project requirements (all options)
- Library paths: the project must see the MARS sources. Either the user installed MARS (Library Path already contains them) or add to the project search path:
[MARS]\Source,[MARS]\ThirdParty\delphi-jose-jwt\Source\Common,[MARS]\ThirdParty\delphi-jose-jwt\Source\JOSE(a git submodule: clone MARS with--recurse-submodules),[MARS]\ThirdParty\mORMot\Source,[MARS]\ThirdParty\Neslib.Yaml,[MARS]\ThirdParty\Neslib.Yaml\Neslib. - `{$I MARS.inc}` must compile — it lives in
[MARS]\Source, so that path is required even for the .dpr. - JWT backend: exactly one of
MARS.mORMotJWT.Token(Windows) orMARS.JOSEJWT.Token(all platforms) must be in the ignition uses clause. The template handles this with{$IFDEF MSWINDOWS}. - Delphi compatibility: 10.4 Sydney through 13 Florence; earlier versions are not supported (
MARS.incstops the build). Packages per IDE version are in[MARS]\Packages\.
Configuration defaults
The engine defaults (from TMARSEngine.Create): Port=8080, PortSSL=0, ThreadPoolSize=75, BasePath=/rest. FEngine.Parameters.LoadFromIniFile overrides them from an ini named like the executable (or passed with the -configFileName <file> command-line switch), section [DefaultEngine]. See the ini template for the commented catalog of common settings (JWT, CORS, compression, SSL, OpenAPI info, FireDAC connection defs).
Adding more pieces
- New resource: create
Server.Resources.<Name>.paswith an attributed class, register it withMARSRegister(TMyResource)ininitialization, and add the unit to the .dpr uses. No engine change needed — the'Server.Resources.*'mask picks it up. - New route module (projects using routes, or when the user asks for them): create
Server.Routes.<Name>.pasregistering a module withMARSRoutes('Server.Routes.<Name>', '<path>', procedure (const R: TMARSRouter) ...)ininitialization, add the unit to the .dpr uses, and make sure the ignition callsLApplication.AddRoutes('Server.Routes.*')(already there inMARSTemplateRoutes). See themars-developmentskill,references/routes.md. - Token/login endpoint: already included (
Server.Resources.Token.passubclassesTMARSTokenResource). OverrideAuthenticateto plug real credential checks. - OpenAPI/Swagger endpoint: see
Demos/MARSTemplate/Server.Resources.OpenAPI.pas(TOpenAPIResource+MARS.OpenAPI.v3.InjectionServicein the ignition uses) and theOpenAPI.info.*ini parameters; the documentation pages are Swagger UI (<app>/www/) and Stoplight Elements (<app>/docs,TOpenAPIElementsResourceofMARS.OpenAPI.Elements). - FireDAC: uncomment the
FireDAC.<DefName>.*entries in the ini; the ignition template already callsTMARSFireDAC.LoadConnectionDefs(FEngine.Parameters, 'FireDAC')under{$IFDEF MARS_FIREDAC}. - Devart UniDAC, MyDAC or IBDAC instead of FireDAC: define
MARS_UNIDAC/MARS_MYDAC/MARS_IBDACin the projects (or inMARS.inc), load the connection defs withTMARS<Lib>.LoadConnectionDefs(FEngine.Parameters, '<Lib>')and add<Lib>.<DefName>.*entries to the ini. See themars-developmentskill,references/devart.md, and the demosDemos/UniDACDemo,MyDACDemo,IBDACDemo(Demos/FireDACDemofor FireDAC).
- Deployment (Windows service install, ISAPI on IIS, Apache module, FastCGI, Linux daemon, HTTPS/SSL, reverse proxy): read
references/deployment.mdin this skill.
For everything about writing resources (attributes, parameter binding, auth, FireDAC and Devart datasets, SSE, WebStencils, clients), consult the companion skill mars-development.
Verify the result
- Compile (IDE or MSBuild against the
.dproj). - Run the server and hit
http://localhost:8080/rest/default/helloworld— expectHello World!astext/plain. - Login check:
POST http://localhost:8080/rest/default/tokenwith form fieldsusernameandpasswordreturns a JSON token. Note: the sampleAuthenticateinTMARSTokenResourceaccepts the current hour (0-23) as password (SameText(APassword, IntToStr(HourOf(Now)))) and grants rolestandard(plusadminfor usernameadmin) — it exists only to make demos runnable. Override it before any real use.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingSkills/mars-new-project/SKILL.md
Popularity
- Repository stars
- 400
- Repository forks
- 118
- 7-day trend score
- 30
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/andrea-magni/mars/mars-new-project)