# Makefile .PHONY Declaration Rules
## Rule
Every target that does NOT produce a file with the same name MUST be declared as .PHONY. This prevents Make from skipping targets when a file with that name exists.
## Why
Without .PHONY, if a file named `test` or `build` exists in the directory, Make considers that target "up to date" and skips it. .PHONY tells Make to always run the target.
## Format
```makefile
# Good: declare .PHONY before each target
.PHONY: build
build:
go build -o bin/app ./cmd/app
.PHONY: test
test:
go test ./...
.PHONY: clean
clean:
rm -rf bin/ dist/
# Also acceptable: grouped declaration
.PHONY: build test clean lint dev deploy
```
## Good
```makefile
.PHONY: test
test: ## Run tests
npm test
```
## Bad
```makefile
test: ## Run tests — MISSING .PHONY
npm test
# If a file named "test" exists, this target is silently skipped!
```
## When .PHONY is NOT Needed
```makefile
# File targets don't need .PHONY
bin/app: cmd/app/main.go
go build -o $@ ./$(<D)
# This produces a file called "bin/app" — Make checks if it's up to date
```