On The Principles of Psychology (1890) chapters 1 & 7, and Psychology, the Briefer Course (1892), the chapters on "The Stream of Thought," "Habit," and some of "The Self."
Can we talk about the mind in a way that is both scientific and also does justice to our everyday experiences? James thought that previous philosophers talking about the mind weren't accurately reflecting how things actually seem to us when we introspect. The empiricists like Locke thought that the basic unit of mentality was the idea, and that particular mental states were combinations of ideas. Spiritualists like Descartes thought that mental states are faculties of a spirit. James found both of these views overly simplistic and ultimately uninformative. He stressed first and foremost that mental activities are in some way unknown to us correlated with brain activities (whether they literally are brain activities is a metaphysical question that can be set aside during science), and that mentality was an evolutionary development, and so psychological explanations should take into account how the organism engages with its environment. These assumptions persist in modern psychology, but the addition that was very in fashion at the beginning of the 20th century, largely because of James, was introspection. In this way, James presages a lot of the findings of phenomenologists like Husserl, Heidegger, and Sartre by being willing to say what experience is really like. James favored direct introspection even while acknowledging that introspective observations, like all observations, are often mistaken. The alternatives as he described them (in Principles Ch. 7) are experimental psychology, which was coming into favor in Germany and bored James to tears, what with the incessant repetition required; and comparative psychology, which would administer surveys to large groups and bring animals, children, and the mentally impaired into their analyses. James thought that we should make use of all of these methods as applicable and not be the servant of any of them.
In "The Stream of Thought" chapter, he reports that consciousness is not a concatenation of discrete ideas, but is a "blooming, buzzing confusion" out of which we make some sort of order, largely through the use of our attention: we pick out some things as salient, and the rest becomes an indistinct fringe. We talk through some of the features of this fringe and the puzzle of what constitutes personal identity, i.e., what makes a particular thought seem owned, what makes it hang together with the rest of the stream of consciousness.
In the second half of the discussion, we turn to habit, which logically comes before all this talk of consciousness, because once something is habitual, you don't need to bring it up before consciousness. James's whole picture of a person's interaction with the outside world is that of a pulse coming in (e.g., through a sense organ), and then a reaction pulse going back out. Sometimes these loops come all the way to consciousness, but sometimes they don't. There are plenty of reactions that are purely reflexes, other more complex ones that are still instinctual, and some that reach all the way into our awareness so that selective attention, deliberation, and/or potentially an effort of will are involved in producing the reaction. Habit is part of that dynamic, where something starts as perhaps a conscious choice or an instinctive reaction, and the more we do it, the more that pulse pathway gets burned into our organism (especially our very plastic brain) so that we're likely to act that same way in the future. James then has a lot of interesting things to say about how best to inculcate good habits and break bad ones.
Buy The Principles of Psychology, Vol. 1 or read it online. Buy Psychology: The Briefer Course or read it online. Most of the text of the latter is verbatim from the longer book; only around 20 percent of the text is new. On the other hand, the longer book is two volumes and contains whole chapters on hypnotism and other weird stuff, so you may prefer the abridgment.
James image by Shane Wood.