u# devlog CLI Tool
A command-line tool that automatically logs git commit messages to your Draft Log API. Perfect for tracking development progress and maintaining a detailed work log.
- π§ Easy Configuration: One-time setup with
devlog config
- π Git Integration: Works seamlessly with git hooks
- π Automatic Logging: Logs commit messages with optional commit hashes
- ποΈ Flexible Usage: Manual logging with custom messages and dates
- π Local Config: Stores configuration securely in
~/.config/devlog.json
# Install globally to use devlog from anywhere
npm install -g devlog-cli
# Clone/download the files to a directory
# Navigate to the directory containing devlog.js and package.json
npm install
npm link # Makes devlog available globally
# Make the script executable
chmod +x devlog.js
# Use directly (requires node-fetch)
npm install node-fetch
./devlog.js
First, you need to configure your API key and preferences:
devlog config
This will prompt you for:
- API Key: Your Draft Log API key (generate one by POST to
/api/users/api-key
) - API Base URL: The base URL for your API (default:
http://localhost:3001
) - Include Commit Hash: Whether to include short commit hashes in logs
- Include Date: Whether to include dates in log entries
Use the built-in install command to automatically set up the post-commit hook:
# Navigate to your git repository
cd /path/to/your/repo
# Install the post-commit hook
devlog install
# If you already have a post-commit hook and want to replace it:
devlog install --force
Alternatively, you can manually set up the post-commit hook:
# Navigate to your git repository
cd /path/to/your/repo
# Copy the post-commit hook
cp post-commit .git/hooks/
# Make it executable
chmod +x .git/hooks/post-commit
Or create the hook manually:
# Create the hook file
cat > .git/hooks/post-commit << 'EOF'
#!/bin/bash
if command -v devlog &> /dev/null && [ -f "$HOME/.config/devlog.json" ]; then
echo "π Logging commit to devlog..."
devlog
fi
EOF
# Make it executable
chmod +x .git/hooks/post-commit
# Log the last git commit message
devlog
# Configure or reconfigure settings
devlog config
# Install post-commit hook in current git repository
devlog install
# Install hook with force (backup existing hook)
devlog install --force
# Log a custom message
devlog log "Fixed critical bug in payment processing"
# Log a custom message with specific date
devlog log "Started new feature" 2025-06-24
# Show help
devlog help
# Set up devlog in a new project
cd my-project
devlog config
devlog install
# After making commits, they'll be logged automatically
git commit -m "Add user authentication"
# Output: π Logging commit to devlog...
# β
Successfully logged to devlog
# Log work that wasn't committed
devlog log "Researched new framework options"
# Log work from a previous date
devlog log "Attended team meeting" 2025-06-23
The configuration is stored in ~/.config/devlog.json
:
{
"apiKey": "your-api-key-here",
"apiBaseUrl": "http://localhost:3001",
"includeCommitHash": true,
"includeDate": true
}
- apiKey: Your API key for authentication
- apiBaseUrl: Base URL for the Draft Log API
- includeCommitHash: Include short commit hash (8 chars) in log entries
- includeDate: Include current date in API requests
When the post-commit hook is installed, every git commit will automatically:
- Check if devlog is available
- Check if devlog is configured
- Get the commit message from the last commit
- Format it according to your preferences
- Send it to your Draft Log API
With commit hash enabled:
[a1b2c3d4] Add user authentication feature
[e5f6g7h8] Fix memory leak in data processing
Without commit hash:
Add user authentication feature
Fix memory leak in data processing
The tool integrates with your Draft Log API using these endpoints:
- Generate API Key:
POST /api/users/api-key
- Append to Log:
POST /api/logs/append
{
"text": "Commit message or custom text",
"date": "2025-06-24" // optional, defaults to today
}
-
"devlog command not found"
- Make sure devlog is installed globally or linked
- Try reinstalling:
npm install -g devlog-cli
-
"No API key found"
- Run
devlog config
to set up your configuration - Check that
~/.config/devlog.json
exists and contains your API key
- Run
-
"Error getting last commit message"
- Make sure you're in a git repository
- Ensure you have at least one commit
- Check git is working:
git log -1 --oneline
-
"API request failed"
- Verify your API key is correct
- Check that your API server is running
- Verify the API base URL in your config
For debugging, you can manually check your configuration:
cat ~/.config/devlog.json
And test your git integration:
git log -1 --pretty=%B # Should show last commit message
To contribute or modify the tool:
# Clone the repository
git clone <repository-url>
cd devlog-cli
# Install dependencies
npm install
# Test locally
./devlog.js help
# Install globally for testing
npm install -g .
MIT License - feel free to use and modify as needed.