Quickstart
This page takes you from an empty directory to a running workspace: a Fresh app, a typed oRPC service, Postgres, Redis, and the Aspire resource graph that runs and observes them. Along the way you learn which files are yours, which files the CLI owns, and which generators to use before you write a feature by hand.
1. Install the CLI
deno install --global --allow-all --name netscript --minimum-dependency-age=0 jsr:@netscript/cli@0.0.9
The command works in Bash and PowerShell. If your shell can't find netscript afterwards, add the
directory that Deno prints to your PATH.
Check that the CLI is on your path:
netscript --help
The public command groups are agent, config, contract, db, deploy, generate, init, marketplace, plugin, service, tokens, ui:add, ui:init, ui:list, ui:remove and ui:update.
2. Scaffold the workspace
netscript init my-app --db postgres --yes
cd my-app
netscript service add --name users --with-client
--yes accepts the remaining defaults without prompting, including the dashboard Fresh app and
the shared Redis cache. service add is a separate step because you run the same command later to
add more services. To set an editor explicitly, add --editor zed, --editor vscode, or
--editor none. netscript init --help lists every option.
The CLI prints how many files and directories it created. The totals depend on the database, service, editor, and agent tooling you chose.
Know what you own
Every entry in the scaffold carries an ownership tag:
[owned]files hold your product code. Your work goes here.[generated]files are rewritten by a generator. Don't patch them.[guidance]files describe the local conventions for people and coding agents.
- my-app/
- AGENTS.md # added by
agent init[guidance] - .agents/skills/ # canonical
agent initskills [generated] - .mcp.json # agent-host MCP wiring [generated]
- .netscript/ # CLI/runtime support [generated]
- apps/dashboard/
- AGENTS.md # app-specific agent rules [guidance]
- WEB-LAYER.md # contract → page → island map [guidance]
- client.ts # Fresh client entry; imports app CSS [owned]
- lib/ # per-service data-layer modules [owned]
- users.ts # users client + query factories [owned]
- utils.ts # web utilities & definePage helper [owned]
- routes/ # Fresh pages and route handlers [owned]
- islands/ # interactive Preact boundaries [owned]
- components/ui/ # copied UI registry source (~60 components) [owned]
- .generated/ # Fresh manifest and route types [generated]
- contracts/versions/v1/ # oRPC routes and Zod boundaries [owned]
- services/users/src/ # contract-bound handler logic (main.ts, routers/) [owned]
- database/postgres/
- schema/schema.prisma # persistence models [owned]
- migrations/ # review and commit [generated history]
- schema/.generated/ # Prisma client + Zod schemas [generated]
- plugins/ # installed capability workspaces [CLI-managed]
- tests/ # workspace-level integration test suite [owned]
- aspire/
- apphost.mts # resource-graph entry point [generated]
- .helpers/ # services/plugins/infrastructure [generated]
- appsettings.json # resource declarations [owned config]
- netscript.config.ts # framework paths and wiring [owned config]
- deno.json # workspace, imports, and tasks [owned config]
- package.json # Node compatibility marker [owned config]
- node_modules/ # local materialised npm dependencies [generated]
- AGENTS.md # added by
Let the CLI decide where files go. The contract, service, db, plugin, and ui:* generators
put new files where the rest of the workspace and Aspire expect them.
3. Start the resource graph
Nothing runs until Aspire starts. From the workspace root, run:
cd aspire
aspire restore
aspire start
In PowerShell, the first step is Set-Location .\aspire; the other commands are the same. The
Windows guidance on this page comes from the CLI source and has not been run on Windows.
In an interactive terminal, aspire start keeps running: leave it open, then open the dashboard URL
that it prints. In a non-interactive shell, such as a CI job or an agent tool call,
aspire start detaches. It prints the AppHost PID and the dashboard URL, then returns while the
resources keep running. The dashboard needs a browser, so read the running graph
from the shell instead:
aspire describe --apphost ./apphost.mts --format Json --non-interactive --nologo
It prints every resource with its allocated endpoint: the Fresh app, the service, Postgres, and
Redis. From an agent host, the MCP tool list_api_services returns the baseUrl, specUrl, and
docsUrl of each resource. Don't use get_app_status or doctor to find endpoints:
get_app_status returns only a health verdict and aggregate counts, without names or URLs, and
reads a telemetry endpoint that defaults to a port Aspire did not allocate; doctor checks project
files on disk, not running processes.
Aspire starts Postgres and Redis, injects service discovery, assigns free ports at runtime, runs
health checks, and collects logs and distributed traces. Because ports are assigned at runtime,
there is no application or service port to memorise. When a copied port, an old terminal, and the
running system disagree, trust the dashboard, aspire describe, or list_api_services.
Wait until the Fresh app, the users service, Postgres, and Redis report healthy. Open a resource
in the dashboard to read its console logs. After you make a request, open the trace view to follow
it across processes. Aspire & the AppHost and
Observability explain the full model.
4. Prepare the database
Leave Aspire running; if it holds your terminal, open a second one. The cd .. below returns from
aspire/ to the workspace root. Each netscript db command starts an operation resource inside the
running AppHost and uses its existing Postgres connection. It doesn't provision another database or
mount .data/postgres again.
cd ..
netscript db init --db postgres --name init
netscript db generate --db postgres
netscript db seed --db postgres
deno task check
This order is required for an Aspire-managed database. If the AppHost is stopped, a db command
fails fast instead of rebuilding the resource graph.
db initcreates and applies the first Prisma migration. Without it, the scaffold has no tables.db generateproduces the Prisma client and the Zod model schemas incrud.ts.db seedruns the workspace seed script.
db init is the first end-to-end checkpoint. When it succeeds, the AppHost resource, the connection
string, the Prisma schema, and the migration path agree, before any product code can hide a failure.
How the database contract is derived
After db generate, @database/zod exports the model schemas and CRUD input schemas. In
deno.json, it resolves to ./database/<engine>/schema/.generated/zod/crud.ts, a NetScript-owned
aggregate that exports <Model>Schema, <Model>CreateInput, and <Model>UpdateInput for every
model in schema.prisma. Derive API contracts from it instead of duplicating Prisma models:
import { UserSchema as DatabaseUserSchema } from '@database/zod';
import { z } from 'zod';
// The scaffolded User model has id, name, createdAt, updatedAt. Pick only fields
// that exist in schema.prisma; introduce new public fields with .extend().
export const UserSchemaV1 = DatabaseUserSchema
.pick({ id: true, name: true, createdAt: true })
.extend({
name: z.string().min(1).max(120),
status: z.enum(['draft', 'active', 'archived']),
});
The generated schema stays the source for column types and nullability. The contract decides what
crosses the boundary and adds the stricter public rules; Contracts & type flow
explains the split. Re-run netscript db generate to rebuild crud.ts for all models after you
change schema.prisma.
Verify your progress
Check every item before you customise anything. An unverified base makes every later failure look like a bug in your code.
- [ ]
netscript --helplists the public command groups shown above. - [ ]
my-app/containsapps/,contracts/,services/,database/,plugins/,aspire/, andtests/. - [ ] Aspire is running, and the dashboard or
aspire describe --apphost ./aspire/apphost.mts --format Jsonshows the Fresh app, theusersservice, Postgres, and Redis with endpoints. MCPlist_api_servicescovers only the HTTP resources, the Fresh app and the service; Postgres and Redis publishtcp://endpoints and don't appear there. - [ ]
netscript db init --name initsucceeded and the initial migration exists. - [ ] The Fresh app answers at the URL shown in the dashboard or by
aspire describe. - [ ]
<fresh-app-url>/designrenders the generated design reference. It answers with an HTTP 302 redirect to/design/tokens, so scripted checks needcurl -L. - [ ]
deno task checkpasses with no errors.
Troubleshooting
- Check that Aspire is still running and its resources are healthy.
- Check that Docker is running, with
docker info. - Check that you ran
aspire restoreinaspire/beforedeno task aspire:start. - Under heavy system load,
aspire restoreoraspire startcan time out withFailed to prepare: A task was canceled. Running the start command again usually succeeds. - Without a browser, read failure diagnostics with the MCP
get_recent_errorstool and resolve endpoints withaspire describe --apphost ./aspire/apphost.mts --format Json. Don't guess the process state. - On Windows, a generated
deno task deps:verifyerror names an incomplete project-local npm materialisation and prints the PowerShell recovery command. Run that command; don't patch a package.
Tour the generated pages
Open two generated pages before you edit anything:
<fresh-app-url>/designrenders the tokens, components, and composition rules already in the app. Read/design/compositionbefore you decide what belongs on the server and what belongs in an island.<service-url>/api/docsis the service's Scalar API reference, generated from the contract that the handler implements. Use it to inspect and call the running oRPC/OpenAPI surface.
Take both base URLs from the dashboard, aspire describe, or list_api_services.
Build a feature through the CLI
Build features with the generators instead of creating folders by hand. From the workspace root,
add an orders contract with one route, then a service and its handler stub:
netscript contract add orders
netscript contract add-route orders recent --method GET --path /orders/recent
netscript service add --name orders --with-client
netscript service add-handler orders recent
contract addcreates the v1 contract, andadd-routeappends therecentprocedure.service add --with-clientcreates the service workspace, registers it with Aspire, and writes the typed data layer atapps/dashboard/lib/orders.ts.service add-handlerbinds that procedure in the correct router with a stub that compiles and throwsNot implementedat runtime.
Replace the throw with your business logic. Don't hand-write a parallel router.
When the feature needs a new table, edit database/postgres/schema/schema.prisma, then migrate and
regenerate so the database and the generated types stay in step:
netscript db migrate --name add_orders
netscript db generate
Pages and UI components
The app comes with a component registry under apps/dashboard/components/ui/: more than 60
components, including data-table, stats-grid, detail-layout, empty-state, panel,
filter-form, and chart-block. The ui:* commands list, copy, update, and remove registry items:
netscript ui:list --project-root apps/dashboard
Use an existing registry item before you build UI by hand:
netscript ui:add <item> --project-root apps/dashboardcopies an item.ui:update --project-root apps/dashboardsyncs the copies you haven't modified.ui:remove <item> --project-root apps/dashboardremoves an item.
To scaffold a Fresh page with a colocated island and query loader, run:
netscript ui:add page orders --island --project-root apps/dashboard
The generator writes apps/dashboard/routes/orders/index.tsx, OrdersIsland.tsx, and
query-loaders.ts. deno task check covers only .ts files under apps/, services/, and
contracts/, so type-check the generated .tsx files directly:
deno check --unstable-kv "apps/dashboard/routes/orders/index.tsx" "apps/dashboard/routes/orders/(_islands)/OrdersIsland.tsx"
The generated page compiles and has the correct file layout. Connect its query loader to the data
layer in apps/dashboard/lib/orders.ts, then implement the feature logic.
For a breaking contract change, start with netscript contract version --help. To add a background
capability, use netscript plugin install <kind>. For example,
netscript plugin install worker --name workers scaffolds the plugin workspace and registers it
with Aspire. The CLI cheat sheet groups the everyday commands by task.
Set up coding agents
If a coding agent will work in the project, install its local guidance and MCP configuration:
netscript agent init
Add --host claude|vscode|opencode|all, --editor none|zed|vscode, or --with-docs as needed. Re-running
the command preserves unrelated host configuration.
agent init configures the client to launch netscript agent mcp, a standard-input/output server
that the client starts; you don't run it by hand. Reach for doctor first when the stack is red,
find_export before you guess a package subpath, list_api_services to resolve runtime URLs
without a browser, and list_service_operations and get_operation_schema before calling the service through its typed client.
Agent tooling documents every tool, its schema, and its safety policy.
Stop the workspace
When you finish, stop the AppHost from the workspace root:
aspire stop --apphost ./aspire/apphost.mts
The Postgres container is declared Persistent in appsettings.json, so it survives AppHost
shutdown. To remove the container and free disk space, use docker stop and docker rm.
Next: build a complete system, chapter by chapter, in the Storefront tutorial. For a single task, such as adding a service, a background job, a screen, or sign-in, pick a recipe in Build.