# Astro Security

> Use when configuring Content Security Policy (CSP) in Astro 6, setting security headers, managing script/style hashes, using nonces, or implementing experimentalStaticHeaders for adapter deployments.

- **Type:** Skill
- **Install:** `agentstack add skill-fusengine-agents-astro-security`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [fusengine](https://agentstack.voostack.com/s/fusengine)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [fusengine](https://github.com/fusengine)
- **Source:** https://github.com/fusengine/agents/tree/main/plugins/astro-expert/skills/astro-security

## Install

```sh
agentstack add skill-fusengine-agents-astro-security
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Astro Security

## Agent Workflow (MANDATORY)

Before ANY implementation, use `TeamCreate` to spawn 3 agents:

1. **fuse-ai-pilot:explore-codebase** - Analyze existing security config, adapters, headers
2. **fuse-ai-pilot:research-expert** - Verify latest Astro 6 CSP docs via Context7/Exa
3. **mcp__context7__query-docs** - Check CSP compatibility with deployment adapter

After implementation, run **fuse-ai-pilot:sniper** for validation.

---

## Overview

### When to Use

- Enabling CSP in an Astro 6 project (stable in v6.0.0)
- Configuring `security.csp` in `astro.config.mjs`
- Adding SHA-256/384/512 hashes for external scripts or styles
- Using nonces for dynamic script injection
- Setting up `experimentalStaticHeaders` for adapter-based CSP headers

### CSP in Astro 6

Astro 6 ships Content Security Policy as a **stable** feature (previously experimental). When enabled:
- Astro automatically generates SHA hashes for all bundled scripts and styles
- Injects a `` in each page's ``
- Supports `script-src` and `style-src` directives by default

**Limitations:**
- Not supported in `dev` mode — test with `build` + `preview`
- External scripts and styles require manual hash configuration
- Incompatible with `` view transitions (use native View Transition API)
- Shiki syntax highlighter (inline styles) not currently supported

---

## Reference Guide

### Concepts

| Topic | Reference | When to Consult |
|-------|-----------|-----------------|
| CSP overview | [csp-overview.md](references/csp-overview.md) | Understanding CSP in Astro 6 |
| Configuration | [csp-config.md](references/csp-config.md) | All config options |
| Script directive | [script-directive.md](references/script-directive.md) | script-src configuration |
| Style directive | [style-directive.md](references/style-directive.md) | style-src configuration |
| Nonces | [nonces.md](references/nonces.md) | Dynamic script injection |
| Static headers | [static-headers.md](references/static-headers.md) | Adapter-based CSP headers |

### Templates

| Template | When to Use |
|----------|-------------|
| [csp-basic.md](references/templates/csp-basic.md) | Basic CSP enable with algorithm |
| [csp-advanced.md](references/templates/csp-advanced.md) | Full config with directives + static headers |

---

## Best Practices

1. **Always test with build + preview** — CSP is inactive in dev mode
2. **Start with SHA-512** — strongest hash algorithm
3. **Use `'self'` explicitly** — not included by default in resources
4. **Hash external scripts manually** — compute SHA hashes for CDN resources
5. **Combine with adapter headers** — use `experimentalStaticHeaders` for Vercel/Netlify

---

## Forbidden

- Testing CSP in `dev` mode (doesn't work — always use `build + preview`)
- Using `` with CSP enabled
- Forgetting to add `'self'` when using `resources` array
- Adding `unsafe-inline` (defeats purpose of CSP)

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [fusengine](https://github.com/fusengine)
- **Source:** [fusengine/agents](https://github.com/fusengine/agents)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-fusengine-agents-astro-security
- Seller: https://agentstack.voostack.com/s/fusengine
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
