Major additions: - Add CODING_GUIDELINES.md with "NO EMOJIS" rule - Create code-fixer agent for automated violation fixes - Add offline mode v2 hooks with local caching/queue - Add periodic context save with invisible Task Scheduler setup - Add agent coordination rules and database connection docs Infrastructure: - Update hooks: task-complete-v2, user-prompt-submit-v2 - Add periodic_save_check.py for auto-save every 5min - Add PowerShell scripts: setup_periodic_save.ps1, update_to_invisible.ps1 - Add sync-contexts script for queue synchronization Documentation: - OFFLINE_MODE.md, PERIODIC_SAVE_INVISIBLE_SETUP.md - Migration procedures and verification docs - Fix flashing window guide Updates: - Update agent configs (backup, code-review, coding, database, gitea, testing) - Update claude.md with coding guidelines reference - Update .gitignore for new cache/queue directories Status: Pre-automated-fixer baseline commit Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
163 lines
4.6 KiB
Markdown
163 lines
4.6 KiB
Markdown
# Making Periodic Save Task Invisible
|
|
|
|
## Problem
|
|
The `periodic_save_check.py` script shows a flashing console window every minute when run via Task Scheduler.
|
|
|
|
## Solution
|
|
Use `pythonw.exe` instead of `python.exe` and configure the task to run hidden.
|
|
|
|
---
|
|
|
|
## Automatic Setup (Recommended)
|
|
|
|
Simply re-run the setup script to recreate the task with invisible settings:
|
|
|
|
```powershell
|
|
# Run from PowerShell in D:\ClaudeTools
|
|
.\.claude\hooks\setup_periodic_save.ps1
|
|
```
|
|
|
|
This will:
|
|
1. Remove the old task
|
|
2. Create a new task using `pythonw.exe` (no console window)
|
|
3. Set the task to run hidden
|
|
4. Use `S4U` logon type (background, no interactive window)
|
|
|
|
---
|
|
|
|
## Manual Update (If Automatic Doesn't Work)
|
|
|
|
### Option 1: Via PowerShell
|
|
|
|
```powershell
|
|
# Get the task
|
|
$TaskName = "ClaudeTools - Periodic Context Save"
|
|
$Task = Get-ScheduledTask -TaskName $TaskName
|
|
|
|
# Find pythonw.exe path
|
|
$PythonExe = (Get-Command python).Source
|
|
$PythonDir = Split-Path $PythonExe -Parent
|
|
$PythonwPath = Join-Path $PythonDir "pythonw.exe"
|
|
|
|
# Update the action to use pythonw.exe
|
|
$NewAction = New-ScheduledTaskAction -Execute $PythonwPath `
|
|
-Argument "D:\ClaudeTools\.claude\hooks\periodic_save_check.py" `
|
|
-WorkingDirectory "D:\ClaudeTools"
|
|
|
|
# Update settings to be hidden
|
|
$NewSettings = New-ScheduledTaskSettingsSet `
|
|
-AllowStartIfOnBatteries `
|
|
-DontStopIfGoingOnBatteries `
|
|
-StartWhenAvailable `
|
|
-ExecutionTimeLimit (New-TimeSpan -Minutes 5) `
|
|
-Hidden
|
|
|
|
# Update principal to run in background (S4U = Service-For-User)
|
|
$NewPrincipal = New-ScheduledTaskPrincipal -UserId "$env:USERDOMAIN\$env:USERNAME" -LogonType S4U
|
|
|
|
# Update the task
|
|
Set-ScheduledTask -TaskName $TaskName `
|
|
-Action $NewAction `
|
|
-Settings $NewSettings `
|
|
-Principal $NewPrincipal
|
|
```
|
|
|
|
### Option 2: Via Task Scheduler GUI
|
|
|
|
1. Open Task Scheduler (taskschd.msc)
|
|
2. Find "ClaudeTools - Periodic Context Save" in Task Scheduler Library
|
|
3. Right-click → Properties
|
|
|
|
**Actions Tab:**
|
|
- Click "Edit"
|
|
- Change Program/script from `python.exe` to `pythonw.exe`
|
|
- Keep Arguments: `D:\ClaudeTools\.claude\hooks\periodic_save_check.py`
|
|
- Click OK
|
|
|
|
**General Tab:**
|
|
- Check "Hidden" checkbox
|
|
- Under "Configure for:" select "Windows 10" (or your OS version)
|
|
|
|
**Settings Tab:**
|
|
- Ensure "Run task as soon as possible after a scheduled start is missed" is checked
|
|
- Ensure "Stop the task if it runs longer than:" is set to 5 minutes
|
|
|
|
4. Click OK to save
|
|
|
|
---
|
|
|
|
## Verification
|
|
|
|
Check that the task is configured correctly:
|
|
|
|
```powershell
|
|
# View task settings
|
|
$TaskName = "ClaudeTools - Periodic Context Save"
|
|
Get-ScheduledTask -TaskName $TaskName | Select-Object -ExpandProperty Settings
|
|
|
|
# Should show:
|
|
# Hidden: True
|
|
|
|
# View task action
|
|
Get-ScheduledTask -TaskName $TaskName | Select-Object -ExpandProperty Actions
|
|
|
|
# Should show:
|
|
# Execute: ...pythonw.exe (NOT python.exe)
|
|
```
|
|
|
|
---
|
|
|
|
## Key Changes Made
|
|
|
|
### 1. pythonw.exe vs python.exe
|
|
- `python.exe` - Console application (shows command window)
|
|
- `pythonw.exe` - Windowless application (no console, runs silently)
|
|
|
|
### 2. Task Settings
|
|
- Added `-Hidden` flag to task settings
|
|
- Changed LogonType from `Interactive` to `S4U` (Service-For-User)
|
|
- S4U runs tasks in the background without requiring an interactive session
|
|
|
|
### 3. Updated Output
|
|
The setup script now displays:
|
|
- Confirmation that pythonw.exe is being used
|
|
- Instructions to verify the task is hidden
|
|
|
|
---
|
|
|
|
## Troubleshooting
|
|
|
|
**Script still shows window:**
|
|
- Verify pythonw.exe is being used: `Get-ScheduledTask -TaskName "ClaudeTools - Periodic Context Save" | Select-Object -ExpandProperty Actions`
|
|
- Check Hidden setting: `Get-ScheduledTask -TaskName "ClaudeTools - Periodic Context Save" | Select-Object -ExpandProperty Settings`
|
|
- Ensure LogonType is S4U: `Get-ScheduledTask -TaskName "ClaudeTools - Periodic Context Save" | Select-Object -ExpandProperty Principal`
|
|
|
|
**pythonw.exe not found:**
|
|
- Should be in same directory as python.exe
|
|
- Check: `Get-Command python | Select-Object -ExpandProperty Source`
|
|
- Then verify pythonw.exe exists in that directory
|
|
- If missing, reinstall Python
|
|
|
|
**Task not running:**
|
|
- Check logs: `Get-Content D:\ClaudeTools\.claude\periodic-save.log -Tail 20`
|
|
- Check task history in Task Scheduler GUI
|
|
- Verify the task is enabled: `Get-ScheduledTask -TaskName "ClaudeTools - Periodic Context Save"`
|
|
|
|
---
|
|
|
|
## Testing
|
|
|
|
After updating, wait 1 minute and check the logs:
|
|
|
|
```powershell
|
|
# View recent log entries
|
|
Get-Content D:\ClaudeTools\.claude\periodic-save.log -Tail 20
|
|
|
|
# Should see entries without any console window appearing
|
|
```
|
|
|
|
---
|
|
|
|
**Updated:** 2026-01-17
|
|
**Script Location:** `D:\ClaudeTools\.claude\hooks\setup_periodic_save.ps1`
|