
# Smart Hibernation

Projects you're not actively working on stay small. When you come back, DevKeepr reinstalls everything so you can pick up right where you left off.

## Start With Stack Detection

DevKeepr uses [Stack Detection](/docs/general/features/stack-detection) to determine which stacks a project uses, and each detected stack can contribute hibernation behavior.

A single project can receive commands from multiple detectors. A Laravel project with Node support might inherit commands such as `rm -rf ./vendor`, `rm -rf ./node_modules`, `php artisan optimize:clear`, `composer install`, `npm install`, and `php artisan view:cache`.

The exact commands depend on the detected stack. There is no single global command list. DevKeepr builds the defaults per project from the matched detectors, and you can override them when needed.

## Automatic Hibernation

Automatic hibernation is schedule-based. A project can be set to:

- `weekly`
- `monthly`
- `quarterly`

If no schedule is set, the project will never hibernate automatically.

When DevKeepr checks for projects to hibernate, it only considers projects that:

- are already detected
- are currently awake
- have a hibernation schedule configured
- have been inactive for at least that schedule

DevKeepr ignores changes to `devkeepr.yaml` when calculating activity, so editing the config file will not keep a project awake by accident.

## Waking A Project

A hibernated project can be woken in two ways:

- manually from the project actions menu
- automatically when DevKeepr detects editor activity or a Git operation and `autoWake` is enabled

When a project wakes, DevKeepr runs its configured wake commands, records the activity, and marks the project as awake again.

## Per-Project Configuration

You can configure hibernation and wake behavior per project in either of these places:

- the project's `devkeepr.yaml`
- the project detail screen under **Hibernation Settings**

In the project detail screen you can:

- enable or disable automatic wake
- enable or disable automatic hibernation
- choose the schedule
- override the global defaults for that project
- edit the hibernate command list
- edit the wake command list
- reset either command list back to the detected stack defaults

![Hibernation settings in the project detail screen](/screenshots/docs/hibernation-settings.webp)

## Example `devkeepr.yaml`

If you want to override the detected defaults, a project config can look like this:

```yaml
$schema: https://devkeepr.app/schema.json

autoWake: true
hibernateSchedule: monthly
hibernateCommands:
  - php artisan optimize:clear
  - rm -rf ./vendor
  - rm -rf ./node_modules
wakeCommands:
  - composer install
  - npm install
  - php artisan view:cache
```

Supported hibernation keys are:

| Key | Description |
|-----|-------------|
| `autoWake` | Wake the project automatically when activity is detected |
| `hibernateSchedule` | `weekly`, `monthly`, `quarterly`, or omitted to disable automatic hibernation |
| `hibernateCommands` | Commands to run when the project hibernates |
| `wakeCommands` | Commands to run when the project wakes |

## Global Defaults

Use the **Hibernation** panel in the sidebar to define global defaults for projects that do not have their own config file.

Global defaults only cover:

- whether default hibernation config is applied at all
- automatic wake
- the automatic hibernation schedule

If a project has its own `devkeepr.yaml`, that project uses its own settings instead. Hibernate and wake commands are still determined per project from stack detection, and you can override them per project when needed.
