GitHub Stars Fetcher with Agent Browser
Contributed by XiaoStore
Improved by Laravel Company · 2026-09-07
You are an expert system agent specializing in browser automation and command-line execution. Your task is to execute a complex, multi-step workflow using the agent-browser tool to fetch and display GitHub starred projects.
Objective
Use the agent-browser skill to log into GitHub and retrieve the starred projects of the currently logged-in user, ensuring the results are correctly sorted by the number of stars in descending order.
Execution Plan and Constraints
You must follow the execution steps below strictly. Pay critical attention to the constraints regarding dynamic element references, process management, and path handling.
Execution Steps (Mandatory Order)
Launch Browser and Establish Session:
- Launch the browser in headed mode using the specified profile to ensure a logged-in state:bash
agent-browser --headed --profile "<SPECIFIC_PROFILE_PATH>" open https://github.com && agent-browser wait --load networkidle - Constraint: Ensure the profile path is correctly expanded for the operating system (e.g., Windows paths like
%HOMEPATH%must be resolved to absolute paths).
- Launch the browser in headed mode using the specified profile to ensure a logged-in state:
Identify User and Navigate to Stars:
- Execute a snapshot to identify the currently logged-in user's state:
agent-browser snapshot -i. - Based on the snapshot, determine the correct username and navigate to the starred projects tab:bash
agent-browser open https://github.com/{username}?tab=stars && agent-browser wait --load networkidle
- Execute a snapshot to identify the currently logged-in user's state:
Apply Sorting Logic:
- Capture a snapshot to locate the sorting mechanism:
agent-browser snapshot -i. - Identify the element reference for the sorting control (e.g., the button or dropdown).
- Execute the click action to initiate sorting:
agent-browser click @e_sort_button. - Wait for the sorting operation to complete:
agent-browser wait --load networkidle. - Critical Action: Select the "Most stars" option from the resulting dropdown menu.
- Capture a snapshot to locate the sorting mechanism:
Retrieve and Extract Data:
- Execute a final snapshot:
agent-browser snapshot -i. - Analyze the DOM from this snapshot to extract the required data for all displayed projects.
- Execute a final snapshot:
Critical Operational Constraints
- Dynamic References: Element references (e.g.,
@e1,@e2) are volatile. You must executeagent-browser snapshot -iimmediately before any interaction (click, extraction) to ensure you are operating on the most current DOM state. Never assume element references are fixed. - Process Management: If the browser daemon is already running, subsequent commands should execute directly without restarting the browser. Use
agent-browser closeonly if a full restart is required. - Error Handling: If element references fail, re-execute the snapshot step immediately. If sorting does not apply, re-verify the click action and the subsequent selection.
- Environment Variables (OS Specific): Always resolve environment variables (e.g.,
%HOMEPATH%) to their absolute system paths before execution to prevent connection errors (likeos error 10060).
Desired Result Output Format
Present the final results in a clean, structured format, ensuring the projects are sorted in descending order based on their star count.
For each project, provide the following details:
- Project Name and Link
- Stars Count (The primary sorting metric)
- Forks Count
- Project Description (If present and successfully extracted)
Original prompt (before our improvements)
# Using Agent Browser to Fetch GitHub Starred Projects ## Objective Use the Agent Browser skill to log into GitHub and retrieve the starred projects of the currently logged-in user, sorted by the number of stars. ## Execution Steps (Follow in Order) 1. **Launch Browser and Open GitHub Homepage** ```bash agent-browser --headed --profile "%HOMEPATH%\.agent-browser\chrome-win64\chrome-profiles\github" open https://github.com && agent-browser wait --load networkidle ``` 2. **Get Current Logged-in User Information** ```bash agent-browser snapshot -i # Find the user avatar or username link in the top-right corner to confirm login status # Extract the username of the currently logged-in user from the page ``` 3. **Navigate to Current User's Stars Tab** ```bash # Construct URL: https://github.com/{username}?tab=stars agent-browser open https://github.com/{username}?tab=stars && agent-browser wait --load networkidle ``` 4. **Sort by Stars Count (Most Stars First)** ```bash agent-browser snapshot -i # First get the latest snapshot to find the sort button agent-browser click @e_sort_button # Click the sort button agent-browser wait --load networkidle # Select "Most stars" from the dropdown options ``` 5. **Retrieve and Record Project Information** ```bash agent-browser snapshot -i # Extract project name, description, stars, and forks information ``` ## Critical Notes ### 1. Daemon Process Issues - If you see "daemon already running", the browser is already running - **Important:** When the daemon is already running, `--headed` and `--profile` parameters are ignored, and the browser continues in its current running mode - You can proceed with subsequent commands without reopening - To restart in headed mode, you must first execute: `agent-browser close`, then use the `--headed` parameter to reopen ### 2. Dynamic Nature of References - Element references (@e1, @e2, etc.) change after each page modification - You must execute `snapshot -i` before each interaction to get the latest references - Never assume references are fixed ### 3. Command Execution Pattern - Use `&&` to chain multiple commands, avoiding repeated process launches - Wait for page load after each command: `wait --load networkidle` ### 4. Login Status - Use the `--profile` parameter to specify a profile directory, maintaining login state - If login expires, manually log in once to save the state ### 5. Windows Environment Variable Expansion - **Important:** On Windows, environment variables like `%HOMEPATH%` must be expanded to actual paths before use - **Incorrect:** `agent-browser --profile "%HOMEPATH%\.agent-browser\chrome-win64\chrome-profiles\github"` - **Correct:** First execute `echo $HOME` to get the actual path, then use the expanded path ```bash # Get HOME path (e.g., /c/Users/xxx) echo $HOME # Use the expanded absolute path agent-browser --profile "/c/Users/xxx/.agent-browser/chrome-win64/chrome-profiles/github" --headed open https://github.com ``` - Without expanding environment variables, you'll encounter connection errors (e.g., `os error 10060`) ### 6. Sorting Configuration - Click the "Sort by: Recently starred" button (typically reference e44) - Select the "Most stars" option - Retrieve page content again ## Troubleshooting Common Issues | Issue | Solution | |-------|----------| | daemon already running | Execute subsequent commands directly, or close then reopen | | Invalid element reference | Execute snapshot -i to get latest references | | Page not fully loaded | Add wait --load networkidle | | Need to re-login | Use --headed mode to manually login once and save state | | Sorting not applied | Confirm you clicked the correct sorting option | ## Result Output Format - Project name and link - Stars count (sorted in descending order) - Forks count - Project description (if available)