apply-screenplay-pattern
Skill4 starsChanged 3 months agoMITView on GitHub
WHEN/WHERE/WHO: [Scheduling: SDETs, developers, or agents writing or refactoring automated acceptance tests.] HOW: [Structural: Use this SKILL to structure test code around Actors, Tasks, Interactions, Abilities, and Questions rather than Page Objects.] WHY: [Scheduling: Page Objects bloat into massive "God classes". Screenplay applies SOLID principles to test code.]
In this repository61 other files it gives its agents.
- activate-personalSkill
- analyze-with-tactics-questionnairesSkill
- apply-agile-testing-quadrantsSkill
- apply-architectural-tacticsSkill
- apply-attribute-driven-designSkill
- apply-fundamentals-of-data-visualizationSkill
- apply-oopsi-modelSkill
- apply-specification-by-exampleSkill
- blog-topic-discoverSkill
- build-agent-memory-systemsSkill
- build-business-objectives-modelSkill
- build-data-dictionarySkill
- build-feature-treeSkill
- comment-alive-test-driven-developmentSkill
- conduct-event-stormingSkill
- create-ecosystem-mapSkill
- create-living-documentationSkill
- create-skill-from-bookSkill
- CREATING-SKILL-TEMPLATESkill
- define-architectural-driversSkill
- define-bounded-contextsSkill
- define-ubiquitous-languageSkill
- design-agentic-screenplay-modelSkill
- design-agent-perception-layersSkill
- design-agent-planningSkill
- design-agent-reward-functionsSkill
- design-agents-using-patternsSkill
- design-architecture-viewpointsSkill
- design-autonomous-ai-interfacesSkill
- design-ddd-aggregatesSkill
- design-tool-use-sandboxingSkill
- document-architectural-decisionsSkill
- document-legacy-codebaseSkill
- doc-with-usage-exampleSkill
- draft-srs-documentSkill
- elicit-requirements-modelsSkill
- evolve-skill-with-wikiSkill
- extract-business-rulesSkill
- facilitate-example-mappingSkill
- facilitate-user-story-mappingSkill
- implement-agent-observabilitySkill
- implement-agent-reflectionSkill
- improve-existing-skillSkill
- improve-user-storySkill
- managing-ai-projectsSkill
- orchestrate-multi-agent-collaborationSkill
- prioritize-requirementsSkill
- review-c4-modelSkill
- review-data-engineeringSkill
- save-as-skillSkill
- scaffold-cmake-cxx-sanitize-gtest-envSkill
- skill-commonSkill
- task-commit-triggerSkill
- test-case-with-demoSkill
- test-case-with-readmeSkill
- test-driven-developmentSkill
- UnitTesting-convert2CaTDDSkill
- update-my-resumeSkill
- update-spec-contextSkill
- validate-requirements-criteriaSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 7 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
When this skill is activated, first load skill-common and apply the shared conventions it defines: canonical section order, frontmatter …
- Distinctive: line 42
Transfer Check: Verify the workflow still works for UI-heavy tests, API-driven tests, and mixed interaction suites.
- Distinctive: line 43
Stop Rule: If the input is a pure unit test with no external interfaces, stop and redirect to a simpler testing approach.
- Very specific: line 46
Tasks: should describe business intent (e.g., LoginWithCredentials) and should NOT contain WebDriver or API specific code.
- Distinctive: line 51
If the input is just a simple unit test for a pure logic function (no external interfaces), stop and inform the user that the Screenplay …
- Distinctive: line 59
Read the scenario steps. For each major business action (e.g., "logs in", "searches for a flight"), define a Task.
- Distinctive: line 79
Verify that no Task contains direct calls to WebDriver (or other low-level API clients).
- Distinctive: line 80
Verify that no Page Object or Interaction contains assertions.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Apply Screenplay Pattern
Common Contract (Load First)
When this skill is activated, first load skill-common and apply the shared conventions it defines: canonical section order, frontmatter rules, anti-pattern guidance, and the Review In Mind loop in review-in-mind. This skill adds only domain-specific rules below.
Who
Software Development Engineers in Test (SDETs), Developers, and AI Agents. The agent uses this skill to architect clean, scalable test automation code.
What
This skill implements the Screenplay Pattern, popularized by Serenity BDD and Serenity/JS. It replaces traditional Page Objects with an actor-centric model. Instead of calling methods on a LoginPage class, you instruct an Actor (who has Abilities like browsing the web) to perform a Task (which is composed of lower-level Interactions and Questions).
When
Invoke this skill when automating BDD scenarios, refactoring messy test scripts, or building an automation framework from scratch. Trigger phrases include: "use the screenplay pattern," "refactor these page objects," "create an actor and tasks," or "implement this using Serenity/JS."
Where
Applies to test automation codebases (Java/Cucumber, TypeScript/Playwright, etc.).
Why
When UI tests rely heavily on Page Objects, tests become tightly coupled to the UI structure. If the UI changes, tests break. Furthermore, Page Objects do not easily support non-UI interactions (like calling a REST API). The Screenplay Pattern abstracts the "what" (the business task) from the "how" (the UI or API interaction), allowing tests to survive UI overhauls.
Inputs
- An automated test script, a set of Page Objects, or a Gherkin scenario.
Output (Logical Evidence)
- Refactored test code separated into Actors, Tasks, Interactions, and Questions.
Optimization Readiness
- Failure Signals: Tasks contain low-level API code, questions become assertions inside tasks, abilities are over-shared, or the design falls back to page-object style coupling.
- Evidence To Collect: Actor/ability maps, task definitions, interaction chains, questions, and examples of refactors that reduced UI coupling.
- Safe Mutation Boundaries: Refine actor naming, task decomposition, interaction guidance, and question design without changing the core Screenplay separation of intent and mechanism.
- Acceptance Criteria: Accept revisions only if tasks stay business-focused, interactions own framework-specific code, and questions are the assertion boundary.
- Rejected Revision Handling: Record page-object spillover, direct WebDriver calls in tasks, and assertion placement mistakes so they are not repeated.
- Transfer Check: Verify the workflow still works for UI-heavy tests, API-driven tests, and mixed interaction suites.
- Stop Rule: If the input is a pure unit test with no external interfaces, stop and redirect to a simpler testing approach.
Constraints (Logical Boundaries)
- Tasks should describe business intent (e.g.,
LoginWithCredentials) and should NOT contain WebDriver or API specific code. - Interactions handle the low-level execution (e.g.,
Click.on,Enter.theValue) and are the only place where framework-specific code lives. - Questions extract state from the application to be used in assertions. Do NOT put assertions directly inside Tasks or Page Objects.
One More Thing
If the input is just a simple unit test for a pure logic function (no external interfaces), stop and inform the user that the Screenplay Pattern is designed for integration and end-to-end testing, not simple unit tests.
How (Structural Workflow)
Phase 1: Identify the Actor and Abilities
- Identify the Actor representing the user in the scenario.
- Determine what Abilities the actor needs (e.g.,
BrowseTheWeb,CallAnApi).
Phase 2: Define Tasks
- Read the scenario steps. For each major business action (e.g., "logs in", "searches for a flight"), define a Task.
- Name the task using domain language (e.g.,
SearchForFlights.from(origin).to(destination)).
Phase 3: Define Interactions and Questions
- Inside each Task, compose the sequence of Interactions required to complete it (e.g.,
Click,Enter,Navigate). - Identify the assertions in the scenario (the
Thensteps). Create Questions that query the state of the system, so the Actor can ensure the expected state is met.
Resources
- Screenplay Components
Review In Mind (ReviewInMindGenie)
Execute the common review loop in review-in-mind before delivering.
Review lens for this skill:
- Are Actors, Tasks, Interactions, Abilities, and Questions cleanly separated (no Page-Object god classes)?
- Does each Task expose a single user-facing intent composed of small interactions?
- Would the suite remain readable and maintainable as the UI evolves?
Validation
- Verify that no Task contains direct calls to WebDriver (or other low-level API clients).
- Verify that no Page Object or Interaction contains assertions.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

