I struggled for a couple of hours on just the basics of creating a package and getting it found. No matter what I tried, I kept getting the annoying and uninformative error:
Error in startup script: can't find package FooBar 1.0
Here is the bare minimum for a pure-Tcl package called FooBar:
package provide foobar 1.0
You can use the pkg_mkIndex utility, but it is often easier to just write this by hand. Basically, you need to call [package ifneeded] to tell the package system about how to load your package. The load script is going to be a [source] command, using the variable $dir
package ifneeded foobar "source [file join $dir FooBar.tcl]"
lappend auto_path /some/where