ワンクリックで
implement-playwright-method
Implement a Playwright method in effect-playwright by analyzing source code and mapping types
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Implement a Playwright method in effect-playwright by analyzing source code and mapping types
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Upgrade playwright-core and update effect-playwright to match new APIs and breaking changes.
Analyze a Playwright method's source code to determine if it can throw errors (sync or async).
| name | implement-playwright-method |
| description | Implement a Playwright method in effect-playwright by analyzing source code and mapping types |
I guide you through implementing a Playwright method in the effect-playwright library. This involves analyzing the original Playwright source code to determine behavior (throwing vs. non-throwing) and mapping types to the Effect ecosystem (Effect, Option, Stream).
Use this skill when you need to add a missing method to effect-playwright or update an existing one.
First, find the implementation of the method in the Playwright codebase to understand its behavior.
context/playwright/packages/playwright-core/src/client/.page.ts, locator.ts, browser.ts, frame.ts, elementHandle.ts.Determine if the method can throw and what it returns. Do not blindly follow existing patterns in effect-playwright. Always analyze the original Playwright source code to determine behavior.
Promise, it interacts with the Playwright server and can throw (e.g., timeouts, target closed).
Effect<Return, PlaywrightError>.Effect<Return, PlaywrightError> (using Effect.sync or Effect.try).url(), locator(), getByRole()).
Effect.page.url(), use page.url() in the effect wrapper, not a getter page.url.Promise<T> -> Effect<T, PlaywrightError>Promise<void> -> Effect<void, PlaywrightError>T (Safe Sync) -> T (Direct return)T (Factory) -> Wrapper<T> (e.g., PlaywrightLocator.Service)T | null -> Option<T> (if sync) or Effect<Option<T>, PlaywrightError> (if async)Page) -> Wrapped Object (e.g., PlaywrightPage)Some Playwright interfaces expose other classes as properties (e.g., Page.keyboard, Page.mouse, BrowserContext.tracing).
PlaywrightKeyboardService wrapping Keyboard).Effect.Example (Interface in Parent):
export interface PlaywrightPageService {
/**
* Access the keyboard.
* @see {@link Page.keyboard}
*/
readonly keyboard: PlaywrightKeyboardService;
}
Example (Implementation in Parent's make):
static make(page: Page): PlaywrightPageService {
return PlaywrightPage.of({
// Initialize the sub-API wrapper synchronously
keyboard: PlaywrightKeyboard.make(page.keyboard),
// ...
});
}
Add the method to the Service interface in the corresponding src/X.ts file (e.g., PlaywrightPageService in src/page.ts).
Example (Async Method - Throws):
/**
* Click the element.
* @see {@link Page.click}
*/
readonly click: (
selector: string,
options?: Parameters<Page["click"]>[1]
) => Effect.Effect<void, PlaywrightError>;
Example (Sync Factory - Safe):
/**
* Creates a locator.
* @see {@link Page.locator}
*/
readonly locator: (
selector: string,
options?: Parameters<Page["locator"]>[1]
) => typeof PlaywrightLocator.Service;
Example (Sync Method - Safe):
/**
* Returns the page URL.
* @see {@link Page.url}
*/
readonly url: () => string;
Example (Nullable Return):
/**
* Returns the text content (Async).
* @see {@link Locator.textContent}
*/
readonly textContent: Effect.Effect<Option.Option<string>, PlaywrightError>;
Implement the method in the make function of the implementation class (e.g., PlaywrightPage.make).
Async Methods: Use useHelper(originalObject).
click: (selector, options) => use((p) => p.click(selector, options)),
Sync Safe Methods: Return directly.
url: () => page.url(),
Factories: Return the wrapped object directly.
locator: (selector, options) => PlaywrightLocator.make(page.locator(selector, options)),
Nullable Returns: Use Option.fromNullable.
// Async nullable
textContent: use((l) => l.textContent()).pipe(
Effect.map(Option.fromNullable)
),
// Sync nullable safe
attribute: (name) => Option.fromNullable(element.getAttribute(name)),
Returning Playwright Objects: Wrap them.
// Async returning object (e.g., waitForEvent returning a Page)
waitForPopup: use((p) => p.waitForEvent("popup")).pipe(
Effect.map(PlaywrightPage.make)
),
PlaywrightXService.pnpm exec biome check --write . to ensure code style and lint rules are followed.pnpm type-check and pnpm test to verify implementation.