Astro Site Management — Agent Knowledge
Capabilities
You can manage an Astro static site through these operations:
- Create, edit, and delete blog posts (markdown/MDX in content collections)
- Import documents (.docx, .pdf) and convert them to markdown
- Upload and organize images in src/assets/
- Edit components (.astro), layouts, and pages
- Edit MDX files with interactive components
- Modify global and component-scoped styles
- Push changes to git for automatic Cloudflare Workers deployment (or run
npx wrangler deploy) - Run npm commands (build, dev, add packages)
Content Collections
Content collections use src/content/ with a schema defined in src/content/config.ts.
Blog Posts
Location: src/content/blog/*.md or *.mdx
Required frontmatter:
---
title: "Post Title"
description: "SEO description"
pubDate: 2024-01-15
---
Optional fields: updatedDate, heroImage, draft, tags
Creating a Post
- Write the markdown file with frontmatter to
src/content/blog/<slug>.md - Place any images in
src/assets/<slug>/ - Reference images:
 - Git add, commit, push to deploy
Querying Collections
In .astro pages:
---
import { getCollection } from "astro:content";
const posts = await getCollection("blog");
const sorted = posts.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
---
Component Patterns
Basic .astro Component
---
const { title, class: className } = Astro.props;
---
<section class:list={["section", className]}>
<h2>{title}</h2>
<slot />
</section>
<style>
.section { padding: 2rem; }
</style>
Layout Pattern
---
import BaseHead from "../components/BaseHead.astro";
import Header from "../components/Header.astro";
import Footer from "../components/Footer.astro";
const { title, description } = Astro.props;
---
<html lang="en">
<head><BaseHead title={title} description={description} /></head>
<body>
<Header />
<main><slot /></main>
<Footer />
</body>
</html>
Dynamic Routes
File: src/pages/blog/[...slug].astro
---
import { getCollection } from "astro:content";
export async function getStaticPaths() {
const posts = await getCollection("blog");
return posts.map((post) => ({ params: { slug: post.slug }, props: post }));
}
const post = Astro.props;
const { Content } = await post.render();
---
<Content />
Safety Rules
- NEVER delete the
.gitdirectory - NEVER delete
node_modules/orpackage-lock.jsonunless reinstalling - NEVER force-push (
git push --force) - NEVER push to branches other than the configured deployment branch
- Do NOT modify
astro.config.mjsorwrangler.tomlwithout explicit user request - NEVER run
rm -rfon the project root - Ask confirmation before deleting any component or page file
Common Tasks
Add a blog post
write_fileto createsrc/content/blog/<slug>.mdwith frontmatter + contentgit_operationsstatus → add → commit → push
Import a document
convert_documentwith the uploaded file pathread_filethe generated markdown to review- Edit frontmatter if needed with
write_file git_operationsadd → commit → push
Edit a component
read_filethe component to understand current codewrite_filewith the updated componentgit_operationsadd → commit → push
Change site styling
read_filethe relevant CSS file or componentwrite_filewith updated stylesgit_operationsadd → commit → push
Upload an image
- Save image to
src/assets/<folder>/usingwrite_fileorrun_command - Reference in markdown:
 - Or in .astro:
import img from "~/assets/<folder>/image.jpg"

