The template has example code that shows the patterns of the app. An app that you make from the template does not need it. scripts/remove-examples.cs deletes all of it in one run:
dotnet run scripts/remove-examples.cs
dotnet build FullstackTemplate.slnxThen commit the result. The script changes only a clean git tree. A second run changes nothing. If the script stops before the end, it prints the command that undoes its changes. Correct the cause, undo the changes, and run it again.
The script does these steps:
- It deletes each tracked folder named
Examples,examples, or(examples). - It deletes each section between an
example:startcomment and anexample:endcomment, in all other tracked files. - It writes the EF Core model snapshot again, so that the snapshot has no example tables.
- It writes the generated files again: the OpenAPI document of the Server, the generated API client of the SPA, and
routeTree.gen.ts. - It writes
scripts/examples-removed.txt. Keep this file. When the app has it,scripts/template-merge.csdeletes the examples from each template update, so that a template update adds no example code again. See Take updates from the template.
A marker with no partner stops the script before it changes a file. A change to the model of the Server with no migration also stops it, because the script deletes the migration that it adds to write the snapshot. Do not put a marker at the start of a line in a code block of a doc, because the script reads it as a marker.
| Example | Where it is |
|---|---|
The weather API and its page at /weather |
FullstackTemplate.Server/Examples/Weather/, frontend/src/examples/weather/, frontend/src/routes/(examples)/weather.tsx |
The component library at /components and the filter builder demo at /filter-demo |
frontend/src/routes/(examples)/ |
The Examples menu of the sidebar |
frontend/src/examples/example-nav.tsx, frontend/src/examples/example-nav-items.ts |
The venues and workshops API, its list_workshops and cancel_workshop MCP tools, and the manage_workshops permission |
FullstackTemplate.Server/Examples/Venues/, FullstackTemplate.Server/Examples/Workshops/, FullstackTemplate.Server/Databases/EntityConfigurations/Examples/, FullstackTemplate.Server/Databases/Migrations/Examples/ |
The workshop pages at /workshops and /venues/new: the list, the detail, the edit and create forms, and the venue picker |
frontend/src/examples/workshops/, frontend/src/examples/venues/, frontend/src/routes/(examples)/workshops/, frontend/src/routes/(examples)/venues/ |
The files of a workshop: the WorkshopAttachment entity and its upload rules, its upload, list, and delete endpoints, its table, and the Files section of the workshop detail. The parts of attachments that it uses are not an example (see attachments.md) |
FullstackTemplate.Server/Examples/Workshops/, frontend/src/examples/workshops/components/workshop-attachments.tsx |
The welcome email: the SendWelcomeEmail job, its handler, and the handler of UserCreated that queues the job. IEmailSender and LogEmailSender are not an example. While the example is in the app, BulkInsertAsync refuses a new user, because UserCreated has a handler |
FullstackTemplate.Server/Examples/WelcomeEmails/ |
| The tests of the examples | the Examples/ and examples/ folders of the test projects, of frontend/tests/, and of frontend/src/ |
| The recipes of the example pages in the verify skill | .agents/skills/verify-fullstack-template/features/examples/ and recipes/examples/ |
The script deletes the migrations of the example tables. A database that ran them still has the venues, workshops, and workshop_attachments tables and the manage_workshops permission. If the database of your app ran those migrations, add a migration that drops the three tables and calls migrationBuilder.DeletePermission("manage_workshops"). A row of a permission that Permission does not know stops each load of its user. The object storage of the app still has the files of the workshops under tenants/<tenant>/workshops/. The sweep of the bucket deletes them, but it does not run while the database has a migration that the Server does not know. So also delete the rows of the example migrations from __EFMigrationsHistory. The script prints this paragraph when it deletes the examples.
Put example code where the script finds it:
- Put a file that is only an example in a folder named
Examples(.NET),examples(the SPA and the tests), or(examples)(a TanStack Router route group, which adds no segment to the URL). - Put example lines in a shared file between two comments. Use the comment form of the file:
// example:startand// example:endin C# and TypeScript,# example:startin YAML and shell,<!-- example:start -->in Markdown, and{/* example:start */}in JSX. - Do not let code outside the examples use example code. After the script runs, that code does not compile.
- Do not add a demo page outside
(examples).frontend/src/each-page-has-a-link.test.tsfails when the URL of a page outside(examples)is in no string of the code that the script keeps. It reads the strings, so these limits apply:- It passes when a string in core code has the URL. A reviewer must look for a demo page with an unmarked link in core code, and for a string that has the URL and is not a link, such as
from: '/demo'. A link from a page that the script keeps counts, also when no user can reach that page. A link in a marked section counts until the script deletes it, so only thewithout-examplesjob of CI finds that case. A page with a parameter is the weakest case: any string of the same shape counts, so/things/newpasses for/things/$id. - It fails when a page has a way in with no whole URL in a string: a URL that starts with a variable (
${base}/things), a relative link (./edit),Route.to, a URL from the Server, or a link from outside the app. Add such a page toPAGES_WITH_ANOTHER_WAY_INin the test.
- It passes when a string in core code has the URL. A reviewer must look for a demo page with an unmarked link in core code, and for a string that has the URL and is not a link, such as
- Keep each
// new-feature:<slot>marker ofscripts/new-feature.csout of an example section. The new-feature script adds its lines above the marker, also in an app with no examples.
The new-feature job of CI is in scripts/ci/new-feature.cs. CI runs this script, so a local run does the same steps:
dotnet run scripts/ci/new-feature.csThe script works on a throwaway copy of the checkout, with your uncommitted changes in the copy. It does not change the checkout. A pass deletes the copy. A failure names the step and keeps the copy, for its logs and test reports. The script needs the .NET SDK band of CI (10.0.4xx), Docker, and buf.
The without-examples job of CI runs the script, runs it again to prove that the second run changes nothing, and fails if an example name stays in a tracked file. Then it builds the app and runs all of the tests. The other CI jobs test the app with the examples.
The steps of the job are in scripts/ci/examples/without-examples.cs. Run it before you push a change to example code, to a marker, or to a line in a doc that can name an example. It works on a throwaway copy, as scripts/ci/new-feature.cs does, and it also needs pnpm:
dotnet run scripts/ci/examples/without-examples.csTo run the new-feature job on an app with no examples, as its second matrix entry does, run dotnet run scripts/ci/new-feature.cs -- --examples remove. This also needs pnpm.
The name check skips the .Designer.cs file of each migration. EF Core writes the full model into that file when it adds the migration, so each migration that you add while the examples are in the app names the example entities. This is harmless. The file names each entity in a string, so the app builds with no example code. EF Core reads the file only for the model at its own migration, and a new migration compares the model with the snapshot, which the script writes again.
When you add an example, add each name that only the example uses to ExampleNames in scripts/ci/examples/without-examples.cs. Use a word that the app does not use for its own code, for example the name of the entity or of the route. The check cannot find the names by itself: a marker gives no name, and the files of an example also use shared names, such as Route and Tenants.
The init job of CI makes an app from the parent commit, deletes its examples, and merges the commit with scripts/template-merge.cs. It fails if the merge has a conflict or adds an example file again.