A personal CLI tool that automatically syncs your Target work schedule from MyTime and provides a natural language assistant powered by Claude AI to answer questions about your shifts.
- Auto-sync — logs into MyTime via a headless Playwright browser and extracts your upcoming shifts
- Local SQLite storage — schedule data persists in
~/.local/share/target-agent/schedule.db - AI assistant — ask natural language questions about your schedule using the Anthropic API
- Desktop notifications — systemd timers fire reminders 60 and 15 minutes before each shift
- Manual fallback — add shifts by hand if the scraper can't parse the page
- Secure config — credentials stored at
~/.config/target-agent/config.json(chmod 600, never in the repo)
| Layer | Technology |
|---|---|
| CLI framework | Click |
| Terminal UI | Rich |
| Browser automation | Playwright (async, persistent context, anti-bot evasion) |
| Database | SQLite via sqlite3 (stdlib) |
| AI | Anthropic Claude API (claude-sonnet-4) |
| Scheduling | systemd user-level timers |
Requirements: Python 3.11+, Linux with systemd, notify-send (libnotify)
git clone https://github.com/yourusername/target-agent.git ~/target-agent
cd ~/target-agent
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
playwright install chromium
bash install.shThen add ~/.local/bin to your PATH if it isn't already:
echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc && source ~/.bashrc# First-time setup — enter your employee number, MyTime password, and Anthropic API key
target setup
# Fetch your schedule from mytime.target.com
target sync
# View upcoming shifts (default: next 14 days)
target schedule
target schedule --days 30
# Show next shift only
target next
# Show hours worked this week and month
target hours
# Ask anything in plain English
target ask do I work this weekend
target ask how many hours do I have this month
target ask when is my next closing shift
# Manually add a shift
target add
# Troubleshoot a failed sync with a visible browser window
target sync --debugscraper.py launches a persistent Chromium context via Playwright. It logs in with human-like typing delays and random pauses to avoid bot detection, handles SMS-based two-factor authentication interactively, navigates to the schedule view, and extracts shifts by querying known CSS selectors with a full-page text fallback. Parsed shifts are upserted into SQLite.
agent.py builds a system prompt with today's date, hours worked this week/month, and the full ±30-day schedule window, then sends the user's question to Claude. This gives Claude all the context it needs without any retrieval step, keeping latency low.
notifier.py is called every 10 minutes by a systemd timer. It checks for any upcoming shifts within 24 hours and fires a notify-send desktop notification at the 60-minute and 15-minute marks.
target-agent/
├── target.py # CLI entry point (Click commands)
├── scraper.py # Playwright-based MyTime scraper
├── agent.py # Claude AI assistant
├── db.py # SQLite helpers
├── notifier.py # Desktop notification logic
├── config.py # Credential management
├── install.sh # Setup script (bin wrapper + systemd units)
├── target-sync.service / .timer # Daily schedule sync
└── target-notify.service / .timer # Shift reminder (every 10 min)
- Credentials are never stored in the repository
- The config file is written with
chmod 600(owner read/write only) - The Playwright browser profile is stored locally and also excluded from git
MIT