logo Buffalo slack logo


Tasks are small scripts that are often needed when writing an application. These tasks might be along the lines of seeding a database, parsing a log file, or even a release script. Buffalo uses the grift package to make writing these tasks simple.

Writing Tasks

Tasks must all be in the grifts package. A simple task would look like following:

var _ = grift.Add("hello", func(c *grift.Context) error {
  return nil

Tasks Generator

$ buffalo g task foo:bar

--> grifts/bar.go
// grifts/bar.go
package grifts

import (
  . "github.com/gobuffalo/grift/grift"

var _ = Namespace("foo", func() {

  Desc("bar", "TODO")
  Add("bar", func(c *Context) error {
    return nil


Listing Available Tasks

$ buffalo task list

Available grifts
buffalo task db:seed       # Seeds a database
buffalo task middleware    # Prints out your middleware stack
buffalo task routes        # Print out all defined routes
buffalo task secret        # Generate a cryptographically secure secret key

Running Tasks


Tasks can be run in development using the buffalo task command.

$ buffalo task hello

From a Built Binary

After a binary has been built, the tasks can be run with the task subcommand:

$ myapp task hello