Skip to content

Instantly share code, notes, and snippets.

@GrahamMcBain
Last active October 26, 2025 01:36
Show Gist options
  • Select an option

  • Save GrahamMcBain/8b03241ad950728c02a7e8c509ffaac6 to your computer and use it in GitHub Desktop.

Select an option

Save GrahamMcBain/8b03241ad950728c02a7e8c509ffaac6 to your computer and use it in GitHub Desktop.
AMP Time Toolbox - Time tracking utilities for enforcing minimum work durations

AMP Time Toolbox

A collection of time-tracking utilities for AMP that allow you to enforce minimum work durations and track time spent on tasks.

Installation

  1. Create your AMP toolbox directory:
mkdir -p ~/.amp/toolbox
export AMP_TOOLBOX="$HOME/.amp/toolbox"
  1. Download and make executable:
# Download all three scripts to ~/.amp/toolbox/
chmod +x ~/.amp/toolbox/now
chmod +x ~/.amp/toolbox/elapsed  
chmod +x ~/.amp/toolbox/wait-until

Usage

Basic Time Tracking

# Capture start time
start_time=$(amp now)

# Work on your task...

# Check elapsed time
amp elapsed $start_time

# Wait until minimum duration (e.g., 3 minutes = 180 seconds)
amp wait-until $start_time 180

# Or simply ask Amp to to take it's time and set a duration
"I want you to work on this problem for at least ten minutes, if you think you're done, check the time and keep iterating until you've reached ten minutes"

Example: Enforce 3-minute minimum work session

start_time=$(amp now)
echo "Starting work session at timestamp: $start_time"

# Do your work here...

# Ensure you worked for at least 3 minutes
amp wait-until $start_time 180
echo "Work session complete!"

Commands

  • amp now - Get current Unix timestamp
  • amp elapsed <timestamp> - Get seconds elapsed since timestamp
  • amp wait-until <timestamp> <min_seconds> - Block until minimum duration passes

Perfect for ensuring AMP takes adequate time on complex tasks!

#!/usr/bin/env bash
# Usage: amp elapsed <start_timestamp>
# Returns seconds elapsed since the given timestamp
set -euo pipefail
if [ $# -ne 1 ]; then
echo "Usage: amp elapsed <start_timestamp>" >&2
exit 1
fi
start_time="$1"
current_time=$(date +%s)
elapsed=$((current_time - start_time))
echo "$elapsed"
#!/usr/bin/env bash
# Usage: amp wait-until <start_timestamp> <minimum_seconds>
# Blocks until at least minimum_seconds have elapsed since start_timestamp
set -euo pipefail
if [ $# -ne 2 ]; then
echo "Usage: amp wait-until <start_timestamp> <minimum_seconds>" >&2
exit 1
fi
start_time="$1"
min_duration="$2"
while true; do
current_time=$(date +%s)
elapsed=$((current_time - start_time))
if [ "$elapsed" -ge "$min_duration" ]; then
echo "Minimum duration of ${min_duration} seconds has elapsed (${elapsed}s total)"
break
fi
remaining=$((min_duration - elapsed))
echo "Still working... ${remaining} seconds remaining"
sleep 5
done
#!/usr/bin/env bash
# Usage: amp now
# Returns current Unix timestamp (seconds since epoch)
set -euo pipefail
date +%s
#!/usr/bin/env bash
# Usage: amp wait-until <start_timestamp> <minimum_seconds>
# Blocks until at least minimum_seconds have elapsed since start_timestamp
set -euo pipefail
if [ $# -ne 2 ]; then
echo "Usage: amp wait-until <start_timestamp> <minimum_seconds>" >&2
exit 1
fi
start_time="$1"
min_duration="$2"
while true; do
current_time=$(date +%s)
elapsed=$((current_time - start_time))
if [ "$elapsed" -ge "$min_duration" ]; then
echo "Minimum duration of ${min_duration} seconds has elapsed (${elapsed}s total)"
break
fi
remaining=$((min_duration - elapsed))
echo "Still working... ${remaining} seconds remaining"
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment