Routines / Custom-Routines / Writing-Instructions

Writing Instructions

The instructions you write for a routine define its behavior — what it should do, how it should do it, and what to avoid. Good instructions are the difference between a routine that works perfectly and one that’s unpredictable.

Structure of good instructions

A well-written set of instructions typically includes:

• What the routine is — A brief description of its purpose

• What it should do — The main task, step by step

• How to format output — What results should look like

• Edge cases — How to handle unusual situations

• What NOT to do — Important constraints and guardrails

Example

Here’s an example of well-structured instructions for a bill tracking routine:

Key principles

Be specific

Good: “When a new email arrives, check if it’s from a known contact. If yes, keep in inbox. If no, add the ‘unknown’ label and archive.”

Vague instructions produce inconsistent behavior. Specify exactly what you want.

Define edge cases

What happens when:

• The email doesn’t fit any category?

• Information is missing?

• The email is ambiguous?

Specify output format

If your routine generates output (summaries, reports), define the format:

Include constraints

Tell the routine what NOT to do. This is just as important as telling it what to do:

Use headers and structure

Well-organized instructions are easier for your assistant to follow:

Common patterns

The classifier

For routines that categorize and route emails:

The reporter

For routines that generate summaries:

The watcher

For routines that monitor and alert:

What your instructions can reference

Your instructions have automatic access to context that gets filled in at runtime:

• Current time — For time-based decisions

• Your email address — For identifying your own messages

• Account info — Which Gmail account is active

• Trigger context — The email, calendar event, or other trigger data

You don’t need to ask for these — they’re automatically available when the routine runs.

Testing your instructions

• Start with approval-required mode — See what the routine wants to do before it does it

• Use manual triggers — Test on specific emails or events

• Check the run history — Review the decisions and actions your assistant took

• Iterate — Refine your instructions based on what you see

Common mistakes

No structure: A wall of text is harder for your assistant to follow consistently

Missing edge cases: “Process bills” — but what if the email is ambiguous?

No output format: Routine generates inconsistent summaries each time

Conflicting rules: “Archive all newsletters” + “Keep important emails in inbox” — what if a newsletter is important?

Tips

Read stock routine instructions. Export a stock routine and study its instructions. These have been tested and refined over time.

Ask your assistant to build it. It generates instructions based on your description. Use the result as a starting point and customize from there.

Test incrementally. Start with the basics. Add edge cases and constraints as you see issues in the run history.

Include logging. Tell your routine to log its reasoning — for example, “Log why you classified each email.” This makes it much easier to understand behavior and fix issues.