AI guidesReusable building blocks

What Is a Snippet? An Engineer's Guide to Reusable Pieces of Code and Text

How many times this week did you type the same paragraph in a quote, or hunt again for the same Excel formula? A snippet lets you save that piece once and paste it in a second. This guide shows what snippets are, where you meet them in AI, coding and office work, and how to use them without getting burned.

8 min read

01What is a snippet, in one sentence

A snippet is a short piece of code or text meant to be reused. It can be a five-line Python function, an Excel formula, a standard closing paragraph for emails, or a prompt that works well with Claude.

Why bother? So you stop retyping the same thing, so the whole office writes and calculates the same way, and so you save time and typos. A piece that was checked once and saved does not need to be checked again every time.

Note: in search, the word snippet also has a completely different meaning, the summary Google shows under a result. More on that below.

02Think of a rubber stamp on the desk

Old offices had stamps: "Checked and approved", "True copy", the company address. Nobody wrote those by hand each time, they just stamped. A snippet is a digital stamp: a ready, checked piece you drop in with one action instead of rewriting it and getting one letter wrong.

03Where you meet snippets

AI

A code block in an AI answer

When you ask Claude or ChatGPT for a script, the code appears in its own box with a copy button. That is a classic code snippet.

Office

Text-expander snippets

Text expander apps, and your operating system's text replacement setting, turn a short code like ;thanks into a full paragraph.

AI

Saved prompts

A prompt that worked great for reviewing a report or summarising a meeting, saved and pasted again instead of rewritten.

Code

VS Code snippets

The VS Code editor lets you define a short trigger that expands into a whole block of code, such as a standard header for every calculation script.

Websites

Excel formulas and HTML embeds

A standard check formula, or embed code you paste into a website: a Google Analytics tag, a YouTube video or a calculator.

Other meaning

Google's featured snippet

A different meaning altogether: the highlighted answer box Google sometimes shows above the results, quoting a piece of a web page.

04The safe path: from a Claude answer to your file

  1. 1Ask and understandAsk Claude for a line-by-line explanation, not just the code
  2. 2CopyUse the box's copy button so no character or space is lost
  3. 3Test on a copyRun it on a copy of the file or a test site, never the original
  4. 4Check by handTry one case where you already know the answer
  5. 5Save with a nameA clear name and a short note: what it does, when, who checked it

05Where to keep your favourite prompts

Fastest

A text expander

Type a short trigger and the full prompt appears, in any app or website. Best for short prompts you use daily.

Standing context

Claude Project instructions

A Project can hold standing instructions that apply to every chat inside it, such as "always answer in Hebrew, in SI units". Availability depends on your plan. See Context that stays.

Full procedure

A Skill

When a prompt has grown into a full procedure with a template and checklist, turn it into a Skill that Claude loads by itself when needed. See Procedures for AI.

Simplest

A plain text file or shared doc

The simple option: one document with all your good prompts, sorted by topic. Works for any team, nothing to install.

06Your first VS Code snippet in 5 minutes

  1. 1

    Open snippet settings

    Go to File, Preferences, Configure Snippets, or run Snippets: Configure Snippets from the Command Palette.

  2. 2

    Pick a language

    For example python, so the snippet only appears in Python files. A global file for all languages is also possible.

  3. 3

    Write a name, trigger and body

    Each snippet has a prefix (the trigger you type), a body (the lines inserted) and an optional description.

  4. 4

    Save and try it

    In a Python file, type the trigger, pick it from the suggestion list, and the whole block appears.

  5. 5

    Share with the team

    A snippets file in the project's .vscode folder is available to everyone working on that project.

07Example: unit conversion in Python

Structural engineer who writes small scriptsasks
"Write a short Python function that converts kN to kgf and back, with comments in Hebrew and one test I can check by hand."
gets
A few-line function that multiplies by 101.97 (since 1 kN is about 101.97 kgf), plus a test that 10 kN returns about 1019.7 kgf. He saves it as a VS Code snippet with the trigger conv and drops it into every new script.
ToolClaude (chat) and VS Code user snippets

08Example: an Excel formula for an edge distance check

Anchor design engineerasks
"Column B has the minimum edge distance and column C the actual edge distance. Give me a formula that returns OK or CHECK."
gets
A formula like =IF(MAX(C2,B2)=C2,"OK","CHECK") that can be dragged down all rows. The minimum value itself comes from the anchor's ETA or the standard, not from the AI. The formula lives in a template sheet or a text expander.
ToolClaude or ChatGPT, and Excel

09Example: a standard reply to a quote request

Office manager at a contractorasks
Types ;quote inside Gmail or Outlook
gets
The full paragraph appears: thanks for the enquiry, what to send (drawings, quantities, schedule), when the quote will arrive and contact details. Only the name and project are left to fill in.
ToolA text expander app or the operating system's text replacement

10Example: embedding a calculator in the company website

Person who runs an engineering firm's websiteasks
"Give me an HTML snippet that embeds our calculator page inside a site page, full width and 700 pixels high."
gets
A short piece of code with an iframe tag pointing to the calculator's address. In WordPress you paste it into a Custom HTML block. The same goes for a YouTube embed code (Share, then Embed) or a Google Analytics tag. A calculator built as an Artifact can be saved as an HTML file and hosted on your site, see Outputs, not just answers.
ToolClaude, and WordPress

11What you need, where to keep the snippet, and why

NeedWhere to keep itWhy
A sentence or email you send dailyText expander or OS text replacementWorks in every app, a few keystrokes
A prompt you use a lotPrompt document or text expanderInstantly available, easy to improve and share
Standing instructions for one topicClaude Project instructionsApplies automatically to every chat in the project
A full procedure with template and checklistSkillClaude loads it by itself when the task fits
A code block repeated across scriptsVS Code user snippetsInserted with a trigger, shareable with the team
An Excel check formulaTemplate sheet with a noteChecked once, stays consistent
Embed code for a websiteA tidy text file or a saved WordPress blockNo more hunting for the code on every new page

12FAQ

Can I run code from Claude without understanding it?

Better not. Ask for a line-by-line explanation, run it first on a copy of the file, and check it against a case where you know the answer. This matters most for VBA macros that change files or delete data.

What about passwords and API keys?

Never paste a snippet that contains a password, API key or token into a chat, a shared doc or a website. If code needs a key, keep it separately (for example in an environment variable) and leave only its name in the code.

Can I copy any code I find online?

Not always. Code on websites and GitHub comes with a licence that says what you may do with it. Before putting such a piece into a commercial product, check the licence, see GitHub without code.

What is the difference between a snippet and a Skill?

A snippet is a piece you paste yourself. A Skill is a package of instructions Claude loads by itself when the task fits. A prompt that has grown into a full procedure is a good candidate for a Skill.

And what is a featured snippet?

It is an SEO term: a highlighted answer box Google sometimes shows above the results, quoting part of a page. It has nothing to do with code, but a short, clear answer near the top of an article improves your chances of appearing there.

Is an old snippet still correct?

Not necessarily. Standards, factors and prices change. Write a date and source in every snippet, and review your list every few months.

More in this guide

The Claude Toolkit: What to Add for Every Task So It Works BetterA kit for every taskWhat Is an Artifact? A Guide for Engineers Who Want More Than a Chat AnswerOutputs, not just answersWhat Is an AI Agent? A Practical Guide for EngineersAI agents at workWhat Are Skills? An Engineer's Guide to Teaching Claude Your Office ProceduresProcedures for AIWhat Is a Connector? How Claude Plugs Into Your Apps (MCP)Claude meets your toolsWhat Is a Plugin? An Engineer's Guide to Installing a Whole Claude Workflow at OnceWorkflow packages for AIWhat Is a Prompt and How Do You Write a Good One?Talking to AIProjects and Memory in Claude: Make It Remember Your WorkContext that staysModels, Tokens and the Context Window: What Happens Behind the ScenesHow AI thinksPictures and Video with Claude: What It Sees, What It Makes, and the WorkaroundsClaude's eyeWhat Is a Design System? A Guide for Non-DesignersDesign without a designerWhat Is GitHub? A Guide for Engineers Who Don't CodeGitHub without codeDesign an image with AI: create, edit and improve pictures, free and paidImages with AIDesigning an AI Character: Mascot, Avatar, Talking Presenter, 3DTask: AI characterEngineering calculations with AI: compute, check and document properlyCalculations with AIBuild engineering software with AI: from a small calculator to an app, without being a programmerSoftware without codingFind a product with AI: search, compare and verify products, suppliers and datasheetsFind and compare productsFind a standard with AI: the right standard and clause, without the hallucinationsStandards, no guessingThe full Claude guideEverything you need to start, step by step

Back to the AI page