Find a comfortable place to write. Bring a recording or a lead sheet of the song for which you want to write a bass part. A recording is ideal because you can play along with it, but printed music will work if you read music.
Listen to the song for which you're writing a bass part. Play along with it. Decide whether you need a simple bass line that stays back to support the song (maybe straight eighth notes on the chord changes) or if you want to write a more complex bass line. The song itself may suggest a bass line. If, for instance, the guitar or another instrument plays a lot of single notes and stays busy in the song, you may want to consider the simple approach. A song that features little movement of other instruments might benefit from a walking bass line or a bass line that plays counter to the melody. This will help create movement in an otherwise static song.
Select notes for your bass part that help support the harmony in the song. If the song is in a minor key, write bass lines that are based around the root note and flatted third of the minor chords used. Returning to these notes in the bass part helps reiterate the minor tonality.
Write with a drummer if you can. Drums and bass often intertwine in a song. Building your bass line around a drum part of a song can help you write a stronger bass part.
Write a bass part that repeats throughout the song. A bass part constantly changing can ruin the rhythmic foundation of your song. That's not to say you have to use only one bass figure. You might write one bass pattern for the verses and write another for the chorus of the song built around the verse pattern with a couple of notes changed added to vary the pattern.