Doc Snapshot Agent
by @wangzhiming1999
Automatically illustrate Markdown documents by turning image markers into screenshots or generated images, then writing an image-enriched Markdown output. Us...
clawhub install doc-snapshot-agentπ About This Skill
name: doc-snapshot-agent description: Automatically illustrate Markdown documents by turning image markers into screenshots or generated images, then writing an image-enriched Markdown output. Use this skill when a document needs screenshots, AI-generated visuals, image placement, or end-to-end document illustration automation. version: 1.0.0 author: Felo Inc license: MIT metadata: hermes: tags: [documentation, markdown, screenshots, image-generation, browser-automation, agent-workflow] homepage: https://github.com/Felo-Inc/felo-skills
Doc Snapshot Agent
doc-snapshot-agent is a single entry-point skill for automatically adding images to Markdown documents.
It supports:
This package is intentionally published as one main skill plus supporting reference documents:
{baseDir}/references/browser-automation.md{baseDir}/references/playwright-mcp.md{baseDir}/references/site-explorer.md{baseDir}/references/image-generation.mdLoad this skill whenever the user asks to:
What This Skill Produces
Input:
Image Summary tableOutput:
Project Root
All input, output, and cache paths are relative to a single project root directory ({project-root}).
At the very beginning of every run, ask the user which directory to use as the project root. If the user declines or says they have no preference, default to /tmp/doc-snapshot-agent.
Once confirmed, all subsequent paths in this skill (cases/, output/, .cache/, etc.) resolve under {project-root}/.
Recommended Directory Layout
{project-root}/
βββ cases/
β βββ {article-id}.md
βββ output/
β βββ {article-id}/
β β βββ raw/
β β β βββ A1_example.png
β β β βββ A2_example.png
β β βββ A1_example.png
β β βββ A2_example.png
β β βββ README.md
β βββ markdowns/
β βββ {article-id}.md
βββ .cache/
βββ screenshots/
βββ {article-id}/
Conventions:
{project-root}/cases/ stores the source Markdown file.{project-root}/output/{article-id}/raw/ stores original browser screenshots and should never be overwritten by later processing.{project-root}/output/{article-id}/ stores final images referenced by Markdown.{project-root}/output/markdowns/ stores the final illustrated Markdown.{project-root}/.cache/screenshots/ stores reusable screenshot cache entries.If the user specifies a different layout, follow the user instruction instead.
Credentials
Some sites require authentication before the requested screenshot can be captured.
Read website credentials from environment variables using this pattern:
PLAYWRIGHT_CRED_{SERVICE}_{FIELD}
Examples:
PLAYWRIGHT_CRED_FELO_EMAILPLAYWRIGHT_CRED_FELO_PASSWORDRules:
Supported Marker Formats
This skill must support both inline markers and summary tables.
Format A: Heading-Based Screenshot Marker
### π· Screenshot: {marker-id} ({filename})
Use: {why this screenshot exists}
Processing: {post-processing instruction}
Difference: {optional distinction from similar screenshots}
Fields:
marker-id: unique screenshot identifier such as A1, B3-1, or D3filename: base filename without the marker prefixUse: what the screenshot should communicateProcessing: crop, resize, or other post-processing needsDifference: optional explanation for how this screenshot differs from similar onesFormat B: HTML Comment Image Marker
Screenshot:
Generated image:
Image Summary Table
A document may end with a summary table listing all required images:
## Image Summary| # | Type | Description | Filename |
|---|------|-------------|----------|
| 1 | generated | Description... | hero.png |
| 2 | screenshot | Description... | dashboard.png |
Important:
Incremental Execution and Resume Behavior
Do not assume the workflow always starts from zero. Before doing any work, inspect the article state and continue from the right step.
Check Existing Artifacts
For a given article id, inspect:
{project-root}/output/{article-id}/raw/*.png{project-root}/output/{article-id}/*.png{project-root}/output/{article-id}/README.md{project-root}/output/markdowns/{article-id}.md{project-root}/.cache/screenshots/{article-id}/Decision Rules
Core Principles
Workflow
Step 0: Verify Playwright MCP Server (MANDATORY)
This check MUST run at the start of EVERY execution, not just the first time.
Before any other work, verify that the Playwright MCP server is properly configured and running:
1. Check for Playwright MCP tools availability
- Attempt to list or detect tools with the mcp__playwright__ prefix
- Required tools include: mcp__playwright__browser_navigate, mcp__playwright__browser_snapshot, mcp__playwright__browser_screenshot
2. If tools are NOT detected, STOP immediately and guide the user to install:
Detect the current client environment and show the matching installation command:
Claude Code
claude mcp add playwright -- npx @playwright/mcp@latest
Codex
codex mcp add playwright -- npx @playwright/mcp@latest
VS Code / Cursor / Kiro (IDE with MCP settings UI)
Add to the MCP settings JSON (e.g. .vscode/mcp.json, .cursor/mcp.json, .kiro/settings/mcp.json):
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}
Standalone MCP Server (headless environments or worker processes)
npx @playwright/mcp@latest --port 8931
Then point the client config to:
{
"mcpServers": {
"playwright": {
"url": "http://localhost:8931/mcp"
}
}
}
Grant Tool Permissions (Claude Code / Codex)
{
"permissions": {
"allow": ["mcp__playwright__*"]
}
}
3. Ask the user to configure and restart the session 4. Do NOT proceed to Step 1 until this check passes
Step 0.5: Confirm the Project Root
After verifying Playwright MCP, ask the user:
> Which directory should I use as the project root for this run?
{project-root}./tmp/doc-snapshot-agent.Create the directory if it does not exist. All subsequent paths (cases/, output/, .cache/, scripts/, references/) resolve under {project-root}/.
Step 1: Parse the Document and Build the Image Inventory
Read the source Markdown and merge image requirements from three sources:
1. inline heading-based screenshot markers
2. inline markers
3. the Image Summary table
For each image, record:
screenshot or generatedAlso detect the target website or websites mentioned by the article.
Step 2: Prepare the Environment
{project-root}/references/playwright-mcp.md before interacting with the sitenpx playwright install chromium before continuingCRITICAL: Browser Tool Requirement
This skill uses only Playwright MCP tools for browser automation. Do NOT use:
mcp__playwright__* prefixAll browser interactions must go through the Playwright MCP server tools:
mcp__playwright__browser_navigatemcp__playwright__browser_snapshotmcp__playwright__browser_screenshotmcp__playwright__browser_clickmcp__playwright__browser_fill_formIf these tools are not available in the current runtime, the workflow cannot proceed. Ask the user to configure the Playwright MCP server first.
Step 2.5: Understand the Target Website Before Taking Screenshots
Bad screenshots usually come from navigating to the wrong page, not from using the wrong screenshot command.
Before capturing anything:
1. Check whether site knowledge already exists under:
- $IMAGE_AGENT_SITE_KNOWLEDGE_DIR/
- $IMAGE_AGENT_SITE_LEARNING_DIR/
2. Derive a stable site-key from the domain name:
- memclaw.me -> memclaw
- app.felo.ai -> felo
3. If {site-key}.md exists and is recent, read it before browsing.
4. If site knowledge is missing or stale, perform a structured site exploration and save the findings into the site knowledge files. See {project-root}/references/site-explorer.md.
5. Map every screenshot description to a specific page or state.
Common mapping mistakes:
dashboard, session history, team members, or invite6. Write a screenshot navigation plan for each image:
7. If new knowledge is discovered while browsing, append it to the site knowledge files so future runs do not repeat the same mistakes.
Step 3: Capture Browser Screenshots
Use the browser automation reference in {project-root}/references/browser-automation.md.
If Playwright MCP is available, also use {project-root}/references/playwright-mcp.md as the concrete execution guide for:
Typical flow:
{project-root}/output/{article-id}/raw/Naming rule:
{marker-id}_{filename}Example:
A1_workspace-dashboard.pngAfter taking each screenshot, verify that the captured image actually matches the description. Do not rely only on DOM text. Visual layout, modals, loading states, overlays, and empty panels must be checked against the real screenshot file.
Step 4: Post-Process Screenshots
Apply the requested processing instructions if present.
Typical operations:
raw/ into the final output directoryPrinciple:
raw/ keeps untouched originals{project-root}/output/{article-id}/ are the assets referenced by MarkdownStep 5: Generate the Illustrated Markdown
This step has two jobs:
#### 1. Replace Inline Markers In Place
Heading marker example:
### π· Screenshot: A1 (workspace-dashboard.png)
Use: Show the authenticated workspace homepage
Processing: Full-width screenshot
becomes:
!Authenticated workspace homepage
HTML comment marker example:
becomes:
!Workspace dashboard showing Architecture Decisions
#### 2. Semantically Place Images Without Inline Markers
For images that appear only in the Image Summary table:
Common mistakes:
Example:
Share panel showing team members and invite controls, prefer the paragraph that mentions inviting teammates rather than the end of a general onboarding section#### 3. Handle Generated Images
For generated images, use the image-generation reference in {project-root}/references/image-generation.md and the bundled script in {project-root}/scripts/generate_image.py.
If generation succeeds, insert the normal Markdown image reference. If generation fails, insert a warning block:
> Warning: AI image generation failed for {filename}
#### 4. Remove the Image Summary Table
The Image Summary block is workflow metadata and should not remain in the final illustrated Markdown.
Step 6: Write the README Inventory
Create {project-root}/output/{article-id}/README.md with metadata such as:
Suggested format:
# {article-id} Illustration OutputArticle: {title}
Completed: {timestamp}
Image Inventory
| Filename | Marker | Description | Size | Processing |
|----------|--------|-------------|------|------------|
| A1_example.png | A1 | Workspace dashboard | 1200x800 | resized |
Notes
Credentials source: environment variables
Additional comments Remaining Work
[ ] Any missing screenshot or failed generated image
Cache Policy
Use a simple file-based screenshot cache:
{project-root}/.cache/screenshots/{article-id}/Special Cases
Generated Images
When an image type is generated, do not mark it as missing by default. Generate it.
Prerequisites:
OPENROUTER_API_KEY is availablerequests is installedDefault command:
python {project-root}/scripts/generate_image.py "{description}" -o "{project-root}/output/{article-id}/{filename}"
Use a stronger model for text-heavy images:
python {project-root}/scripts/generate_image.py "{description}" -o "{project-root}/output/{article-id}/{filename}" -m google/gemini-3-pro-image-preview
Generation prompt guidance:
Failure handling:
Multilingual Documents
If the document is language-specific, make sure the captured website matches that language. If the site supports language switching, switch before taking screenshots.
Dynamic Pages
Before taking screenshots:
Output Requirements
When this skill finishes, return a concise summary containing:
Quick Reference
Project root (ask user, default /tmp/doc-snapshot-agent):
{project-root}/Input:
{project-root}/cases/{article-id}.md
Output:
{project-root}/output/{article-id}/raw/*.png
{project-root}/output/{article-id}/*.png
{project-root}/output/{article-id}/README.md
{project-root}/output/markdowns/{article-id}.md
Credentials:
PLAYWRIGHT_CRED_{SERVICE}_{FIELD}
Cache:
{project-root}/.cache/screenshots/{article-id}/
References:
{project-root}/references/browser-automation.md
{project-root}/references/playwright-mcp.md
{project-root}/references/site-explorer.md
{project-root}/references/image-generation.md
Bundled script:
{project-root}/scripts/generate_image.py