Agent context packet

Structured metadata, source alternates, graph links, headings, series position, and diagram inventory for crawlers and agent readers.

Table of contents

  1. The Three Commands
  2. Dev Server
  3. Production Build
  4. Pagefind — Build-Time Search
  5. Cloudflare Pages Deployment
  6. The Full Workflow
  7. What You’ve Learned
  8. Sources

Series context

Learn Astro 6

A ground-up guide to Astro for developers coming from Python, LaTeX, or scientific computing.

  1. The Mental Model
  2. File-Based Routing
  3. .astro Files
  4. Components
  5. Astro Layouts
  6. Content Collections
  7. Astro Styling
  8. Markdown and Code Blocks
  9. Build and Deploy

Entry facts

Kind
guide
Maturity
evergreen
Confidence
high
Origin
ai-drafted (AI-drafted, human-reviewed)
Author
Agent
Directed by
krow
Published
Modified
Words
1,020 (5 min read)
Series
learn-astro #9
Tags
astro, fundamentals
Prerequisites
Full corpus
/llms-full.txt
Readable corpus
/source/full-corpus/

Graph links

Prerequisites astro-mental-model

Tagsastro, fundamentals

Diagram inventory

  1. Cloudflare Pages Deployment Mermaid SVG, Mermaid source, ASCII companion

Build and Deploy

The full pipeline — dev server, production build, Pagefind search, and Cloudflare Pages.

/ directed by / / 5 min read
On this page

The Three Commands

This assumes you have shipped content collections and understand markdown rendering. For the wider stack philosophy see the mental model and the way .astro files compose into static output.

CommandWhat It DoesAnalogy
npm run devStarts live-reload dev server at localhost
jupyter notebook — hot-reloading preview
npm run buildCompiles everything to dist/make all — full production build
npm run previewServes dist/ locallyOpening the final PDF to check it

Dev Server

Terminal window
npm run dev

Opens http://localhost:4321. When you edit an .astro, .md, or .css file, the browser auto-refreshes. Use this while writing content and tweaking design.

Key Insight

The dev server runs your build pipeline on every change, but incrementally — only recompiling what changed. It’s fast because Astro uses Vite under the hood, which does hot module replacement.

Production Build

Terminal window
npm run build

krowdev’s build command chains three steps:

"build": "node scripts/check-mermaid-cache.mjs && astro build && npx pagefind --site dist"
  1. node scripts/check-mermaid-cache.mjs — verifies the pre-rendered Mermaid diagram cache is current before the build
  2. astro build — compiles all pages, optimizes images, downloads fonts, generates sitemap
  3. npx pagefind --site dist — scans the HTML output and builds a search index

The output lands in dist/:

  • dist/
  • index.html# homepage
  • guide/
  • agentic-coding-getting-started/index.html
  • agentic-coding-prompt-patterns/index.html
  • astro-mental-model/index.html
  • ... (one per guide entry)
  • article/
  • welcome-to-krowdev/index.html
  • _astro/
  • fonts/# self-hosted Inter + JetBrains Mono
  • *.css# compiled stylesheets
  • pagefind/# search index
  • pagefind-entry.json
  • fragment/...
  • favicon.svg
  • sitemap-index.xml
Analogy

This dist/ folder is your final artifact — like a compiled binary or a rendered PDF. Everything needed to serve the site is in there. No runtime dependencies, no database, no server process.

Pagefind creates a client-side search engine from your static HTML. It:

  1. Scans all .html files in dist/
  2. Extracts text from elements with data-pagefind-body
  3. Builds a compressed search index
  4. Ships a tiny JS widget that searches the index in the browser

The search index is typically 10-50KB — small enough to load instantly. No server needed.

In krowdev, kb entries have data-pagefind-body on their content area:

<article data-pagefind-body>
<slot />
</article>

This tells Pagefind: “index the content inside this element.” Headers, footers, and sidebars are excluded.

Cloudflare Pages Deployment

Cloudflare Pages serves the dist/ folder. Setup:

  1. Push to GitHub — your repo containing the Astro project at the root
  2. Connect in Cloudflare Dashboard — Workers & Pages → Create → Connect to Git
  3. Configure build:
    • Root directory: leave blank (or set to your subdirectory if you use a monorepo)
    • Build command: npm run build
    • Output directory: dist
    • Environment variable: NODE_VERSION = 24 (match your project’s engines.node)
  4. Auto-deploy — every push to main triggers a rebuild

Pushing code fires a GitHub webhook that triggers a Cloudflare Pages build, which publishes the site.

Push-to-deploy pipelinePushing code fires a GitHub webhook that triggers a Cloudflare Pages build, which publishes the site.

You push code

GitHub webhook

Cloudflare builds

Site goes live

Push-to-deploy pipeline

Cloudflare’s free tier: unlimited bandwidth, 500 builds/month, global CDN. More than enough for a personal blog.

Important

krowdev’s Astro project lives at the repo root, so the root directory is left blank. Only set a root directory (and Cloudflare will cd into it before npm run build) if your Astro project sits in a subdirectory of a monorepo.

The Full Workflow

Here’s what a typical content workflow looks like:

1. Write markdown in content/kb/
2. npm run dev → preview at localhost:4321
3. Happy with it? → git add + git commit
4. git push → Cloudflare auto-deploys
5. Site live at krowdev.pages.dev in ~30 seconds
Analogy

This is like a LaTeX + Makefile + CI/CD pipeline:

Edit .tex → make preview → looks good → git push → CI runs pdflatex → PDF published

Same flow, different tools.

What You’ve Learned

Over 9 lessons, you’ve covered the full Astro architecture:

LessonConceptOne-Liner
01Mental ModelAstro is a compiler, not a server
02File Routingsrc/pages/ directory = URL structure
03.astro FilesCode fence (build time) + template (HTML output)
04ComponentsReusable pieces with props and slots
05LayoutsTemplate inheritance via nested <slot />
06Content CollectionsTyped, validated markdown with query API
07StylingScoped CSS + global tokens + Catppuccin theming
08Markdown & CodeShiki highlighting, MDX for components in content
09Build & Deploydist/ is the artifact, Cloudflare serves it

You now understand every file in krowdev. The codebase has no mysteries.

Final Challenge: Add a real article end-to-end

Do the full workflow:

  1. Create a new kb entry: content/kb/first-article.md
  2. Write valid frontmatter (title, description, kind: guide, tags, maturity, origin, confidence)
  3. Add some content with a code block, a table, and a heading
  4. Preview with npm run dev — check sidebar, ToC, syntax highlighting, dark/light mode
  5. Build with npm run build — verify it compiles and Pagefind indexes it
  6. Check the output: ls dist/guide/first-article/

If all that works, you’ve completed the course. You can now write and publish content to krowdev independently.

Sources

Diagram

Drag to pan · scroll or pinch to zoom · Esc to close