← Back to blog
hoffbit·

Share As Prompt: Making Every Code Snippet AI-Ready

How the Share As Prompt (SAP) standard bridges the gap between code resources and AI agents, turning any code snippet, tool, or cheatsheet into a structured prompt that LLMs can immediately act on.

Key Takeaways

  • SAP wraps code resources in structured metadata that LLMs can parse without ambiguity
  • It eliminates the copy-paste friction between code reference sites and AI workflows
  • Any site can adopt SAP by adding a single button that generates a formatted prompt
  • The format includes context, dependencies, usage patterns, and intent — not just raw code
  • SAP is designed as an open web standard, not a proprietary format
  • vs-code.com already ships SAP buttons on every tool, snippet, and cheatsheet page

## The Copy-Paste Problem Nobody Talks About

Here's a workflow every developer knows: you find a useful code snippet online, copy it, paste it into your AI assistant, then spend the next two minutes explaining what it does, what language it's in, what dependencies it needs, and how it's supposed to be used. The AI asks clarifying questions. You answer them. Eventually, the LLM has enough context to actually help you.

This is absurd. The information existed on the page you copied from. It just wasn't structured in a way your AI could consume.

Share As Prompt (SAP) fixes this.

What SAP Is

SAP is a lightweight content format that wraps code resources — snippets, tools, cheatsheets, components — in structured metadata that any LLM can parse without ambiguity. Think of it as package.json for shareable code context.

When you click a SAP button on a page, instead of getting raw code on your clipboard, you get a formatted prompt that includes:

  • What the code is (type, language, category)
  • What it does (description, summary)
  • The code itself (properly fenced with language hints)
  • What it needs (dependencies, environment requirements)
  • How to use it (usage patterns, examples with expected output)
  • Where it came from (source URL for attribution and reference)

Paste that into Claude, ChatGPT, or any other LLM, and the model immediately has full context. No back-and-forth. No "what language is this?" No "what does this function expect?"

Why This Matters Now

The developer workflow has fundamentally shifted. A growing number of developers don't just read code references — they feed them to AI agents that modify, adapt, and integrate code on their behalf. But the web wasn't built for this workflow.

Most code-sharing sites optimize for human readability: syntax highlighting, nice typography, copy buttons that grab raw text. None of that helps an LLM understand what it's looking at. A syntax-highlighted Python function and a syntax-highlighted TypeScript function look identical to a clipboard — both are just strings.

SAP adds the semantic layer that's missing. It's the difference between handing someone a page torn from a cookbook and handing them the recipe with ingredient quantities, prep time, serving size, and dietary notes included.

How It Works

The SAP format is intentionally simple. It uses Markdown with structured sections that LLMs already understand well:

` # [Resource Title]

Context Type: snippet Source: https://example.com/snippets/debounce Language: typescript

Description A production-ready debounce function with TypeScript generics and cancel/flush support.

Code // ... the actual code ...

Dependencies None (zero-dependency implementation)

Usage Wrap any function to debounce rapid calls. Default delay is 300ms.

Examples Input: debounce(saveForm, 500) Output: Function that waits 500ms after last call before executing ```

No special tooling required. No build step. No API integration. Any site can generate this format from their existing content metadata. If you already have structured data about your code resources (and most sites do — that's how they render their pages), you already have everything you need.

The Standard In Practice

On vs-code.com, every tool, snippet, and cheatsheet page includes a SAP button alongside the traditional copy button. Click "Share As Prompt" and you get the full structured prompt on your clipboard, ready to paste into any AI assistant.

The implementation is straightforward. Each content type on the site already has a typed interface:

  • Tools have language, dependencies, usage, and examples
  • Snippets have tags, variations, and dependencies
  • Cheatsheets have sections with command/description pairs
  • Components have props, styling, and usage patterns

SAP simply maps these existing fields into a prompt-friendly format. The content was already structured — SAP makes that structure portable.

Adopting SAP on Your Site

If you run a developer resource site, adding SAP support takes roughly an afternoon:

  1. Audit your content model. You probably already store metadata like language, description, and tags. SAP just serializes what you have.
  1. Create a prompt generator. A function that takes your content object and outputs a Markdown string following the SAP section format. Fifty lines of code, tops.
  1. Add the button. Place a "Share As Prompt" button next to your existing copy button. On click, generate the SAP string and copy to clipboard.
  1. Optional: Add the SAP meta tag. Include so tools and extensions can discover SAP-enabled pages programmatically.

There's no registry to sign up for, no API key, no approval process. SAP is a format, not a platform.

The Bigger Vision

SAP starts with copy-paste, but the format enables more:

  • Browser extensions that detect SAP-enabled pages and offer one-click prompt generation
  • AI agent tooling that can crawl SAP-enabled sites and build context libraries
  • IDE integrations that let you search and import SAP-formatted resources directly from your editor
  • Cross-site resource sharing where SAP acts as a universal interchange format for code resources

Imagine a world where every documentation site, tutorial platform, and code reference ships SAP-formatted content. Your AI agent could pull in a React hook from one site, a CSS utility from another, and a deployment recipe from a third — each with full context, zero ambiguity.

Not Another Standard (Kind Of)

Yes, I know about the XKCD comic. The difference is that SAP doesn't compete with existing standards — it adds a layer on top of them. Your OpenAPI spec still works. Your JSDoc comments still work. Your README format still works. SAP just makes all of that content shareable in a way that AI agents can consume.

The web already has the data. SAP is just the envelope.

Try It

Head to any tool or snippet page on vscode.com and hit the "Share As Prompt" button. Paste the result into your preferred AI assistant. Watch how much faster the conversation gets productive.

That's the whole pitch: code resources should be AI-ready by default, and SAP makes it trivial to get there.


SAP is an open format. The spec, reference implementation, and adoption guide are available on the vs-code.com GitHub repository. Pull requests welcome.

Code Examples

SAP prompt format structure

# [Tool/Snippet Title]

## Context
Type: tool | snippet | cheatsheet | component
Source: https://example.com/tools/my-tool
Language: typescript

## Description
What this resource does and when to use it.

## Code
\`\`\`typescript
// The actual code content
export function myTool(input: string): string {
  return input.trim().toLowerCase();
}
\`\`\`

## Dependencies
- lodash (optional)

## Usage
Call myTool() with a raw string to normalize it.

## Examples
Input: "  Hello World  " → Output: "hello world"

Enjoyed this article? Share it with a fellow developer.