automation-best-practices

Guide browser automation code with Intuned best practices for selectors and waits.

30|3|Updated Dec 2, 2025
One-click install
npx skills add https://github.com/Intuned/cookbook --skill automation-best-practices
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: automation-best-practices
Source: https://github.com/Intuned/cookbook/tree/main/.claude/skills/automation-best-practices
Command: npx skills add https://github.com/Intuned/cookbook --skill automation-best-practices

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a structured, battle-tested set of guidelines for building reliable and maintainable browser automation scripts with Intuned. It helps teams reduce flaky tests, improve selector resilience, optimize wait strategies, and implement robust SDK patterns.

Core Features & Use Cases

  • Selector guidance: Prefer stable, accessible selectors to reduce brittleness.
  • Waiting strategies: Replace arbitrary sleeps with deterministic waits and DOM/network settling.
  • Anti-detection & performance tips: Apply minimal anti-detection features only when necessary, and optimize for efficiency.
  • Code quality tooling: Use batched evaluations, modular patterns, and a clear review checklist to improve reliability and maintainability.
  • Use Case: A team refactors a flaky Playwright script to rely on semantic selectors, proper waits, and a lightweight auth/session approach, cutting retries by a substantial margin.

Quick Start

Ask an AI assistant to apply these best practices to your automation code. For example: "Refactor a flaky Playwright script to use stable selectors, replace waitForTimeout with conditional waits, and batch DOM extractions."

Frequently Asked Questions about automation-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix flaky browser automation scripts?

Flaky automation scripts often fail due to arbitrary delays and brittle selectors. Replace hard-coded waits with deterministic DOM and network settling helpers, use stable semantic selectors instead of fragile XPath or positional selectors, and implement conditional waits that verify element state before interacting. This reduces retry rates and improves reliability.

What's the best way to choose selectors for automation code?

Prefer stable, accessible selectors that target semantic attributes like data-testid or aria-labels over CSS class names or XPath that break with UI changes. Semantic selectors remain resilient across styling updates and reduce maintenance overhead when refactoring automation scripts.

How do I optimize wait strategies in browser automation?

Replace arbitrary timeouts with intelligent wait strategies: use DOM settling to verify element visibility, network interception to confirm data loads, and conditional checks before actions. Batching evaluations and avoiding pressSequentially() in favor of fill() further improves performance and reduces flakiness.

When should I apply anti-detection techniques in automation?

Apply anti-detection features minimally and only when necessary to avoid detection triggers. Focus first on efficient, maintainable patterns: direct URL building, batched evaluations, and lightweight session management. Over-reliance on anti-detection can degrade performance and introduce maintenance burden.

How do I review automation code for reliability?

Use a structured review checklist covering selector stability, wait determinism, batched DOM extractions, and SDK pattern compliance. Modular code structure, clear separation of concerns, and adherence to no arbitrary delays enforce maintainability and catch reliability issues before deployment.

Can I apply these best practices to existing Playwright scripts?

Yes. Refactor existing Playwright scripts by replacing waitForTimeout with conditional waits, converting brittle selectors to semantic alternatives, and restructuring extractions into batched operations. Teams typically reduce retry rates substantially by applying these patterns incrementally to legacy automation code.