Best practices for writing effective Claude prompts, based on Anthropic guidance as of spring 2026.
XML tags are the strongest signal for separating prompt sections. Claude was trained to treat them as semantic boundaries.
| import { useState } from 'react'; | |
| import isEqual from 'lodash.isequal'; | |
| /** | |
| * Memoizes by deep equality — returns the previous reference when | |
| * content is unchanged, even if the input is a new object. Avoids | |
| * unnecessary downstream invalidation that `useMemo` can't prevent | |
| * when its deps are new references with identical data. | |
| * |
| # Delete local branches merged to the default branch + their worktrees | |
| # Catches both true merges (git) and squash merges (GitHub PR status) | |
| # Reads default branch from origin/HEAD — works with main, staging, etc. | |
| # Usage: trim [--force] (--force skips confirmation) | |
| trim() { | |
| local repo_root | |
| repo_root="$(git rev-parse --show-toplevel 2>/dev/null)" || { echo "Not in a git repo"; return 1; } | |
| local base_branch | |
| base_branch="$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null)" |
| # add to runs tests for both modified and untracked files ending in .test.ts extension | |
| alias jestdiff="git status --porcelain | grep -E '\.test\.ts$' | awk '{print \$2}' | xargs pnpm jest" |
| /** | |
| * pdfMake's getBase64 provides for an async callback that does not allow for error handling (at least in v0.2.x) | |
| * this recreates their OutputDocument.getBase64() behavior with accessible error handling | |
| */ | |
| export const generatePdfBase64 = ( | |
| pdf: TCreatedPdf, | |
| { | |
| endStream = true, | |
| readChunkSize = 1024 * 1024 * 1024, // 1 GiB (matches pdfmake's OutputDocument.bufferSize) | |
| timeoutMs = 15 * 1000, |
| import { Prisma, PrismaClient } from '@prisma/client'; | |
| import get from 'lodash.get'; | |
| describe('prisma extensions', () => { | |
| it('RLS extension sets app policy helpers', async () => { | |
| // #region setup | |
| const userId = 'user_123'; | |
| const organizationId = 'org_456'; | |
| const membershipRole = 'admin'; | |
| const setRlsSql = Prisma.sql`SELECT set_rls_app_context(${userId}, ${organizationId}, ${membershipRole});`; |
Tag Type
has_many :tagsTag
belongs_to :tag_type| // - example rails erb view | |
| // <div id="edit-react-form" | |
| // data-submit-endpoint="<%= billing_profile_path(@billing_profile.token) %>" | |
| // data-initial-values="<%= @form.initial_values.to_json %>" | |
| // data-cancel-url="<%= billing_profile_path(@billing_profile.token) %>" | |
| // > | |
| // </div> | |
| function parsePropsFromDataset(dataset) { | |
| let stringifyedOptions = { ...dataset }; // convert DOMStringMap into Object |
| import * as React from "react"; | |
| import { SmallButton } from "../../shared"; // a cool <button /> | |
| const DisplayLocalStorage = () => { | |
| const [changes, setChanges] = React.useState(0); // triggers re-renders | |
| let localStorageState = {}; | |
| for (let i = 0; i < localStorage.length; i++) { | |
| const key = localStorage.key(i); | |
| let value; |